@aseity/markup 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/LICENSE +13 -0
  2. package/README.md +7 -0
  3. package/dist/chunk-5L4J6AEU.js +53 -0
  4. package/dist/{highlighted-body-2E2RUEVK.js → highlighted-body-IBQRZ35U.js} +1 -1
  5. package/dist/index.d.ts +69 -67
  6. package/dist/index.js +1 -1
  7. package/dist/mermaid-EHIBIOVN.js +2 -0
  8. package/package.json +28 -16
  9. package/styles.css +47 -15
  10. package/dist/chunk-3FMAEQDM.js +0 -44
  11. package/dist/chunk-4C4AVXPR.js +0 -44
  12. package/dist/chunk-6X3KAB3G.js +0 -44
  13. package/dist/chunk-DXRJ7NKV.js +0 -44
  14. package/dist/chunk-EA4GH5YC.js +0 -44
  15. package/dist/chunk-OCWVEFP4.js +0 -44
  16. package/dist/chunk-U6UMAQJI.js +0 -44
  17. package/dist/chunk-UXTVDSGQ.js +0 -44
  18. package/dist/chunk-WV2NZ4BQ.js +0 -44
  19. package/dist/chunk-ZZZFBUN2.js +0 -44
  20. package/dist/highlighted-body-4YSYKEK2.js +0 -2
  21. package/dist/highlighted-body-CR5QBDDG.js +0 -2
  22. package/dist/highlighted-body-DNFTI5Y2.js +0 -2
  23. package/dist/highlighted-body-KTEADN3E.js +0 -2
  24. package/dist/highlighted-body-MDPN53UW.js +0 -2
  25. package/dist/highlighted-body-OCPTMKP5.js +0 -2
  26. package/dist/highlighted-body-Q7XMN4YL.js +0 -2
  27. package/dist/highlighted-body-THAAYXDF.js +0 -2
  28. package/dist/highlighted-body-ZTFV3I3G.js +0 -2
  29. package/dist/mermaid-2MEXZSUX.js +0 -2
  30. package/dist/mermaid-6GVLPXAO.js +0 -2
  31. package/dist/mermaid-BDCW5K2I.js +0 -2
  32. package/dist/mermaid-CYHXXCQK.js +0 -2
  33. package/dist/mermaid-LA5BCIMF.js +0 -2
  34. package/dist/mermaid-PBCGYNS3.js +0 -2
  35. package/dist/mermaid-PMFK6PRR.js +0 -2
  36. package/dist/mermaid-R437CJ3K.js +0 -2
  37. package/dist/mermaid-WFPBTIVQ.js +0 -2
  38. package/dist/mermaid-X7PMS4NC.js +0 -2
package/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright 2023 Vercel, Inc.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,7 @@
1
+ # @aseity/markup
2
+
3
+ 可定制的 React Markdown 渲染组件库,支持流式渲染及代码、数学、图表等插件。
4
+
5
+ 源自 [Vercel Streamdown](https://github.com/vercel/streamdown),经过深度改造,**与上游版本不兼容**。本包使用 `Markup` / `MarkupProps` 导出和 `data-markup` 样式标识,不提供上游兼容别名。
6
+
7
+ 本仓库的安装、调试、插件接入和定制说明见[根目录 README](../../README.md)。许可证为 Apache-2.0,详见 LICENSE。
@@ -0,0 +1,53 @@
1
+ "use client";
2
+ import {createContext,memo,useContext,useMemo,lazy,isValidElement,useId,useTransition,useRef,useEffect,useState,cloneElement,createElement,useCallback,Suspense}from'react';import {harden}from'rehype-harden';import xo from'rehype-raw';import Br,{defaultSchema}from'rehype-sanitize';import Ua from'remark-gfm';import {visitParents,SKIP}from'unist-util-visit-parents';import {clsx}from'clsx';import {twMerge}from'tailwind-merge';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {createPortal}from'react-dom';import {toJsxRuntime}from'hast-util-to-jsx-runtime';import {urlAttributes}from'html-url-attributes';import Ni from'remark-parse';import Ri from'remark-rehype';import {unified}from'unified';import {visit}from'unist-util-visit';import {Lexer}from'marked';var Zr=300,Xr="300px",Gr=500;function tn(e={}){let{immediate:t=false,debounceDelay:n=Zr,rootMargin:o=Xr,idleTimeout:r=Gr}=e,[s,i]=useState(false),a=useRef(null),l=useRef(null),d=useRef(null),c=useMemo(()=>f=>{let p=Date.now();return window.setTimeout(()=>{f({didTimeout:false,timeRemaining:()=>Math.max(0,50-(Date.now()-p))});},1)},[]),m=useMemo(()=>typeof window!="undefined"&&window.requestIdleCallback?(f,p)=>window.requestIdleCallback(f,p):c,[c]),u=useMemo(()=>typeof window!="undefined"&&window.cancelIdleCallback?f=>window.cancelIdleCallback(f):f=>{clearTimeout(f);},[]);return useEffect(()=>{if(t){i(true);return}let f=a.current;if(!f)return;l.current&&(clearTimeout(l.current),l.current=null),d.current&&(u(d.current),d.current=null);let p=()=>{l.current&&(clearTimeout(l.current),l.current=null),d.current&&(u(d.current),d.current=null);},h=w=>{d.current=m(M=>{M.timeRemaining()>0||M.didTimeout?(i(true),w.disconnect()):d.current=m(()=>{i(true),w.disconnect();},{timeout:r/2});},{timeout:r});},b=w=>{p(),l.current=window.setTimeout(()=>{var x,H;let M=w.takeRecords();(M.length===0||(H=(x=M.at(-1))==null?void 0:x.isIntersecting)!=null&&H)&&h(w);},n);},g=(w,M)=>{w.isIntersecting?b(M):p();},y=new IntersectionObserver(w=>{for(let M of w)g(M,y);},{rootMargin:o,threshold:0});return y.observe(f),()=>{l.current&&clearTimeout(l.current),d.current&&u(d.current),y.disconnect();}},[t,n,o,r,u,m]),{shouldRender:s,containerRef:a}}var nn=/\s/,Qr=/^\s+$/,es=new Set(["code","pre","svg","math","annotation"]),ts=e=>typeof e=="object"&&e!==null&&"type"in e&&e.type==="element",ns=e=>e.some(t=>ts(t)&&es.has(t.tagName)),os=e=>{let t=[],n="",o=false;for(let r of e){let s=nn.test(r);s!==o&&n&&(t.push(n),n=""),n+=r,o=s;}return n&&t.push(n),t},rs=e=>{let t=[],n="";for(let o of e)nn.test(o)?n+=o:(n&&(t.push(n),n=""),t.push(o));return n&&t.push(n),t},ss=(e,t,n,o,r,s)=>{let i=`--markup-animation:markup-${t};--markup-duration:${r?0:n}ms;--markup-easing:${o}`;return s&&(i+=`;--markup-delay:${s}ms`),{type:"element",tagName:"span",properties:{"data-markup-animate":true,style:i},children:[{type:"text",value:e}]}},is=(e,t,n,o,r)=>{let s=t.at(-1);if(!(s&&"children"in s))return;if(ns(t))return SKIP;let i=s,a=i.children.indexOf(e);if(a===-1)return;let l=e.value;if(!l.trim())return;let d=n.sep==="char"?rs(l):os(l),c=o.prevContentLength,m=d.map(u=>{let f=r.count;if(r.count+=u.length,Qr.test(u))return {type:"text",value:u};let p=c>0&&f<c,h=p?0:r.newIndex++*n.stagger;return ss(u,n.animation,n.duration,n.easing,p,h)});return i.children.splice(a,1,...m),a+m.length},as=0;function Ne(e){var s,i,a,l,d;let t={animation:(s=e==null?void 0:e.animation)!=null?s:"fadeIn",duration:(i=e==null?void 0:e.duration)!=null?i:150,easing:(a=e==null?void 0:e.easing)!=null?a:"ease",sep:(l=e==null?void 0:e.sep)!=null?l:"word",stagger:(d=e==null?void 0:e.stagger)!=null?d:40},n={prevContentLength:0,lastRenderCharCount:0},o=as++,r=()=>c=>{let m={count:0,newIndex:0};visitParents(c,"text",(u,f)=>is(u,f,t,n,m)),n.lastRenderCharCount=m.count,n.prevContentLength=0;};return Object.defineProperty(r,"name",{value:`rehypeAnimate$${o}`}),{name:"animate",type:"animate",rehypePlugin:r,setPrevContentLength(c){n.prevContentLength=c;},getLastRenderCharCount(){let c=n.lastRenderCharCount;return n.lastRenderCharCount=0,c}}}Ne();var pt=createContext(false),ft=()=>useContext(pt);var ds=/\s+/,Re=(...e)=>twMerge(clsx(e)),us=(e,t)=>{if(!(e&&t))return t;let n=`${e}:`;return t.split(ds).filter(Boolean).map(o=>o.startsWith(n)?o:`${e}:${o}`).join(" ")},sn=e=>e?(...t)=>us(e,twMerge(clsx(t))):Re,X=(e,t,n)=>{let o=typeof t=="string"&&n.startsWith("text/csv")?"\uFEFF":"",r=typeof t=="string"?new Blob([o+t],{type:n}):t,s=URL.createObjectURL(r),i=document.createElement("a");i.href=s,i.download=e,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(s);};var Ue=createContext(Re),k=()=>useContext(Ue);var gs=Re("block","before:content-[counter(line)]","before:inline-block","before:[counter-increment:line]","before:w-6","before:mr-4","before:text-[13px]","before:text-right","before:text-muted-foreground/50","before:font-mono","before:select-none"),cn=e=>{let t={};for(let n of e.split(";")){let o=n.indexOf(":");if(o>0){let r=n.slice(0,o).trim(),s=n.slice(o+1).trim();r&&s&&(t[r]=s);}}return t},ln=(e,t,n)=>{if(!n)return;let[o,...r]=n.split(";"),s=o==null?void 0:o.trim();s&&(e[t]=s),r.length>0&&Object.assign(e,cn(r.join(";")));},dn=memo(({children:e,result:t,language:n,className:o,startLine:r,lineNumbers:s=true,...i})=>{let a=k(),l=useMemo(()=>a(gs),[a]),d=useMemo(()=>{let c={};return ln(c,"--markup-code-bg",t.bg),ln(c,"--markup-code-fg",t.fg),t.rootStyle&&Object.assign(c,cn(t.rootStyle)),c.backgroundColor="transparent",c.color="var(--markup-code-fg, inherit)",c},[t.bg,t.fg,t.rootStyle]);return jsx("div",{className:a(o,"overflow-x-auto bg-transparent px-6 pt-4 pr-14 pb-4 text-[12.25px] leading-5"),"data-language":n,"data-markup":"code-block-body",...i,children:jsx("pre",{className:a(o),style:d,children:jsx("code",{className:s?a("[counter-increment:line_0] [counter-reset:line]"):void 0,style:s&&r&&r>1?{counterReset:`line ${r-1}`}:void 0,children:t.tokens.map((c,m)=>jsx("span",{className:s?l:a("block"),children:c.length===0||c.length===1&&c[0].content===""?`
3
+ `:c.map((u,f)=>{let p={},h=!!u.bgColor;if(u.color&&(p["--markup-code-c"]=u.color),u.bgColor&&(p["--markup-code-tbg"]=u.bgColor),u.htmlStyle)for(let[b,g]of Object.entries(u.htmlStyle))b==="color"?p["--markup-code-c"]=g:b==="background-color"?(p["--markup-code-tbg"]=g,h=true):b==="font-style"?p.fontStyle=g:p[b]=g;return jsx("span",{"data-has-bg":h?"true":void 0,"data-markup":"code-token",style:{...p,backgroundColor:h?"var(--markup-code-tbg)":void 0,color:"var(--markup-code-c, inherit)"},...u.htmlAttrs,children:u.content},f)})},m))})})})},(e,t)=>e.result===t.result&&e.language===t.language&&e.className===t.className&&e.startLine===t.startLine&&e.lineNumbers===t.lineNumbers);var gt=({className:e,language:t,style:n,isIncomplete:o,...r})=>{let s=k();return jsx("div",{className:s("group relative my-4 w-full overflow-hidden rounded-2xl bg-[#f3f3f3] dark:bg-muted/40",e),"data-incomplete":o||void 0,"data-language":t,"data-markup":"code-block",style:{contentVisibility:"auto",containIntrinsicSize:"auto 200px",...n},...r})};var ht=createContext({code:""}),Ke=()=>useContext(ht);var ys={bash:"Shell",c:"C","c++":"C++",cpp:"C++",cs:"C#",csharp:"C#",css:"CSS",dart:"Dart",diff:"Diff",dockerfile:"Dockerfile",go:"Go",golang:"Go",graphql:"GraphQL",html:"HTML",java:"Java",javascript:"JavaScript",js:"JavaScript",json:"JSON",jsx:"JavaScript",kotlin:"Kotlin",less:"Less",lua:"Lua",makefile:"Makefile",markdown:"Markdown",md:"Markdown",perl:"Perl",php:"PHP",powershell:"PowerShell",ps1:"PowerShell",py:"Python",python:"Python",r:"R",rb:"Ruby",rs:"Rust",ruby:"Ruby",rust:"Rust",sass:"Sass",scala:"Scala",scss:"SCSS",sh:"Shell",shell:"Shell",sql:"SQL",svelte:"Svelte",swift:"Swift",ts:"TypeScript",tsx:"TypeScript",typescript:"TypeScript",vue:"Vue",xml:"XML",yaml:"YAML",yml:"YAML",zsh:"Shell"},bt=e=>{var n;let t=e.trim().toLowerCase();return (n=ys[t])!=null?n:null},kt=({language:e})=>{let t=k(),n=bt(e);return n?jsxs("div",{className:t("flex min-h-10 items-center gap-2 px-6 pt-1 pb-1 font-normal text-[12.25px] text-inherit leading-5"),"data-language":e,"data-markup":"code-block-header",children:[jsxs("svg",{"aria-hidden":"true",className:t("shrink-0"),fill:"none",focusable:"false",height:16,stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24",width:16,xmlns:"http://www.w3.org/2000/svg",children:[jsx("path",{d:"m18 16 4-4-4-4"}),jsx("path",{d:"m6 8-4 4 4 4"}),jsx("path",{d:"m14.5 4-5 16"})]}),jsx("span",{children:n})]}):null};var vs=e=>{let t=e.length;for(;t>0&&e[t-1]===`
4
+ `;)t--;return e.slice(0,t)},Is=lazy(()=>import('./highlighted-body-IBQRZ35U.js').then(e=>({default:e.HighlightedCodeBlockBody}))),yt=({code:e,language:t,className:n,children:o,isIncomplete:r=false,startLine:s,lineNumbers:i,...a})=>{let l=k(),d=useMemo(()=>vs(e),[e]),c=useMemo(()=>({bg:"transparent",fg:"inherit",tokens:d.split(`
5
+ `).map(u=>[{content:u,color:"inherit",bgColor:"transparent",htmlStyle:{},offset:0}])}),[d]),m=!bt(t)&&c.tokens.length===1;return jsx(ht.Provider,{value:{code:e},children:jsxs(gt,{isIncomplete:r,language:t,children:[jsx(kt,{language:t}),o?jsx("div",{className:l("pointer-events-none absolute right-2 z-10 flex items-center justify-end",m?"top-1/2 -translate-y-1/2":"top-2"),"data-markup":"code-block-actions-wrapper",children:jsx("div",{className:l("pointer-events-auto flex shrink-0 items-center gap-2"),"data-markup":"code-block-actions",children:o})}):null,jsx(Suspense,{fallback:jsx(dn,{className:n,language:t,lineNumbers:i,result:c,startLine:s,...a}),children:jsx(Is,{className:n,code:d,language:t,lineNumbers:i,raw:c,startLine:s,...a})})]})})};var pn=e=>jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M15.5607 3.99999L15.0303 4.53032L6.23744 13.3232C5.55403 14.0066 4.44599 14.0066 3.76257 13.3232L4.2929 12.7929L3.76257 13.3232L0.969676 10.5303L0.439346 9.99999L1.50001 8.93933L2.03034 9.46966L4.82323 12.2626C4.92086 12.3602 5.07915 12.3602 5.17678 12.2626L13.9697 3.46966L14.5 2.93933L15.5607 3.99999Z",fill:"currentColor",fillRule:"evenodd"})}),fn=e=>jsxs("svg",{className:"lucide lucide-copy",fill:"none",height:16,stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24",width:16,xmlns:"http://www.w3.org/2000/svg",...e,children:[jsx("rect",{height:"14",rx:"2",ry:"2",width:"14",x:"8",y:"8"}),jsx("path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"})]}),gn=e=>jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M8.75 1V1.75V8.68934L10.7197 6.71967L11.25 6.18934L12.3107 7.25L11.7803 7.78033L8.70711 10.8536C8.31658 11.2441 7.68342 11.2441 7.29289 10.8536L4.21967 7.78033L3.68934 7.25L4.75 6.18934L5.28033 6.71967L7.25 8.68934V1.75V1H8.75ZM13.5 9.25V13.5H2.5V9.25V8.5H1V9.25V14C1 14.5523 1.44771 15 2 15H14C14.5523 15 15 14.5523 15 14V9.25V8.5H13.5V9.25Z",fill:"currentColor",fillRule:"evenodd"})}),hn=e=>jsxs("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:[jsx("path",{d:"M8 0V4",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M8 16V12",opacity:"0.5",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M3.29773 1.52783L5.64887 4.7639",opacity:"0.9",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M12.7023 1.52783L10.3511 4.7639",opacity:"0.1",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M12.7023 14.472L10.3511 11.236",opacity:"0.4",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M3.29773 14.472L5.64887 11.236",opacity:"0.6",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M15.6085 5.52783L11.8043 6.7639",opacity:"0.2",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M0.391602 10.472L4.19583 9.23598",opacity:"0.7",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M15.6085 10.4722L11.8043 9.2361",opacity:"0.3",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M0.391602 5.52783L4.19583 6.7639",opacity:"0.8",stroke:"currentColor",strokeWidth:"1.5"})]}),bn=e=>jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M1 5.25V6H2.5V5.25V2.5H5.25H6V1H5.25H2C1.44772 1 1 1.44772 1 2V5.25ZM5.25 14.9994H6V13.4994H5.25H2.5V10.7494V9.99939H1V10.7494V13.9994C1 14.5517 1.44772 14.9994 2 14.9994H5.25ZM15 10V10.75V14C15 14.5523 14.5523 15 14 15H10.75H10V13.5H10.75H13.5V10.75V10H15ZM10.75 1H10V2.5H10.75H13.5V5.25V6H15V5.25V2C15 1.44772 14.5523 1 14 1H10.75Z",fill:"currentColor",fillRule:"evenodd"})}),kn=e=>jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M13.5 8C13.5 4.96643 11.0257 2.5 7.96452 2.5C5.42843 2.5 3.29365 4.19393 2.63724 6.5H5.25H6V8H5.25H0.75C0.335787 8 0 7.66421 0 7.25V2.75V2H1.5V2.75V5.23347C2.57851 2.74164 5.06835 1 7.96452 1C11.8461 1 15 4.13001 15 8C15 11.87 11.8461 15 7.96452 15C5.62368 15 3.54872 13.8617 2.27046 12.1122L1.828 11.5066L3.03915 10.6217L3.48161 11.2273C4.48831 12.6051 6.12055 13.5 7.96452 13.5C11.0257 13.5 13.5 11.0336 13.5 8Z",fill:"currentColor",fillRule:"evenodd"})}),yn=e=>jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M12.4697 13.5303L13 14.0607L14.0607 13L13.5303 12.4697L9.06065 7.99999L13.5303 3.53032L14.0607 2.99999L13 1.93933L12.4697 2.46966L7.99999 6.93933L3.53032 2.46966L2.99999 1.93933L1.93933 2.99999L2.46966 3.53032L6.93933 7.99999L2.46966 12.4697L1.93933 13L2.99999 14.0607L3.53032 13.5303L7.99999 9.06065L12.4697 13.5303Z",fill:"currentColor",fillRule:"evenodd"})}),Cn=e=>jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M13.5 10.25V13.25C13.5 13.3881 13.3881 13.5 13.25 13.5H2.75C2.61193 13.5 2.5 13.3881 2.5 13.25L2.5 2.75C2.5 2.61193 2.61193 2.5 2.75 2.5H5.75H6.5V1H5.75H2.75C1.7835 1 1 1.7835 1 2.75V13.25C1 14.2165 1.7835 15 2.75 15H13.25C14.2165 15 15 14.2165 15 13.25V10.25V9.5H13.5V10.25ZM9 1H9.75H14.2495C14.6637 1 14.9995 1.33579 14.9995 1.75V6.25V7H13.4995V6.25V3.56066L8.53033 8.52978L8 9.06011L6.93934 7.99945L7.46967 7.46912L12.4388 2.5H9.75H9V1Z",fill:"currentColor",fillRule:"evenodd"})}),wn=e=>jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M1.5 6.5C1.5 3.73858 3.73858 1.5 6.5 1.5C9.26142 1.5 11.5 3.73858 11.5 6.5C11.5 9.26142 9.26142 11.5 6.5 11.5C3.73858 11.5 1.5 9.26142 1.5 6.5ZM6.5 0C2.91015 0 0 2.91015 0 6.5C0 10.0899 2.91015 13 6.5 13C8.02469 13 9.42677 12.475 10.5353 11.596L13.9697 15.0303L14.5 15.5607L15.5607 14.5L15.0303 13.9697L11.596 10.5353C12.475 9.42677 13 8.02469 13 6.5C13 2.91015 10.0899 0 6.5 0ZM4.125 5.875H4.75H5.875V4.75V4.125H7.125V4.75V5.875H8.25H8.875V7.125H8.25H7.125V8.25V8.875H5.875V8.25V7.125H4.75H4.125V5.875Z",fill:"currentColor",fillRule:"evenodd"})}),vn=e=>jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M1.5 6.5C1.5 3.73858 3.73858 1.5 6.5 1.5C9.26142 1.5 11.5 3.73858 11.5 6.5C11.5 9.26142 9.26142 11.5 6.5 11.5C3.73858 11.5 1.5 9.26142 1.5 6.5ZM6.5 0C2.91015 0 0 2.91015 0 6.5C0 10.0899 2.91015 13 6.5 13C8.02469 13 9.42677 12.475 10.5353 11.596L13.9697 15.0303L14.5 15.5607L15.5607 14.5L15.0303 13.9697L11.596 10.5353C12.475 9.42677 13 8.02469 13 6.5C13 2.91015 10.0899 0 6.5 0ZM4.125 5.875H4.75H8.25H8.875V7.125H8.25H4.75H4.125V5.875Z",fill:"currentColor",fillRule:"evenodd"})});var Ee={CheckIcon:pn,CopyIcon:fn,DownloadIcon:gn,ExternalLinkIcon:Cn,Loader2Icon:hn,Maximize2Icon:bn,RotateCcwIcon:kn,XIcon:yn,ZoomInIcon:wn,ZoomOutIcon:vn},Tn=createContext(Ee),xs=(e,t)=>{if(e===t)return true;if(!(e&&t))return e===t;let n=Object.keys(e),o=Object.keys(t);return n.length!==o.length?false:n.every(r=>e[r]===t[r])},Ct=({icons:e,children:t})=>{let n=useRef(e),o=useRef(e?{...Ee,...e}:Ee);xs(n.current,e)||(n.current=e,o.current=e?{...Ee,...e}:Ee);let r=o.current;return jsx(Tn.Provider,{value:r,children:t})},E=()=>useContext(Tn);var Ze={copyCode:"Copy Code",downloadFile:"Download file",downloadDiagram:"Download diagram",downloadDiagramAsSvg:"Download diagram as SVG",downloadDiagramAsPng:"Download diagram as PNG",downloadDiagramAsMmd:"Download diagram as MMD",viewFullscreen:"View fullscreen",exitFullscreen:"Exit fullscreen",mermaidFormatSvg:"SVG",mermaidFormatPng:"PNG",mermaidFormatMmd:"MMD",copyTable:"Copy table",copyTableAsMarkdown:"Copy table as Markdown",copyTableAsCsv:"Copy table as CSV",copyTableAsTsv:"Copy table as TSV",downloadTable:"Download table",downloadTableAsCsv:"Download table as CSV",downloadTableAsMarkdown:"Download table as Markdown",tableFormatMarkdown:"Markdown",tableFormatCsv:"CSV",tableFormatTsv:"TSV",imageNotAvailable:"Image not available",downloadImage:"Download image",openExternalLink:"Open external link?",externalLinkWarning:"You're about to visit an external website.",close:"Close",copyLink:"Copy link",copied:"Copied",openLink:"Open link"},Xe=createContext(Ze),O=()=>useContext(Xe);var Ge=({onCopy:e,onError:t,timeout:n=2e3,children:o,className:r,code:s,...i})=>{let a=k(),[l,d]=useState(false),c=useRef(0),{code:m}=Ke(),{isAnimating:u}=useContext(B),f=O(),p=s!=null?s:m,h=async()=>{var y;if(typeof window=="undefined"||!((y=navigator==null?void 0:navigator.clipboard)!=null&&y.writeText)){t==null||t(new Error("Clipboard API not available"));return}try{l||(await navigator.clipboard.writeText(p),d(!0),e==null||e(),c.current=window.setTimeout(()=>d(!1),n));}catch(w){t==null||t(w);}};useEffect(()=>()=>{window.clearTimeout(c.current);},[]);let b=E(),g=l?b.CheckIcon:b.CopyIcon;return jsx("button",{className:a("cursor-pointer rounded-md p-1.5 text-neutral-500 transition-colors hover:bg-black/5 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50 dark:text-muted-foreground dark:hover:bg-white/10",r),"data-markup":"code-block-copy-button",disabled:u,onClick:h,title:f.copyCode,type:"button",...i,children:o!=null?o:jsx(g,{size:14})})};var xn={"1c":"1c","1c-query":"1cq",abap:"abap","actionscript-3":"as",ada:"ada",adoc:"adoc","angular-html":"html","angular-ts":"ts",apache:"conf",apex:"cls",apl:"apl",applescript:"applescript",ara:"ara",asciidoc:"adoc",asm:"asm",astro:"astro",awk:"awk",ballerina:"bal",bash:"sh",bat:"bat",batch:"bat",be:"be",beancount:"beancount",berry:"berry",bibtex:"bib",bicep:"bicep",blade:"blade.php",bsl:"bsl",c:"c","c#":"cs","c++":"cpp",cadence:"cdc",cairo:"cairo",cdc:"cdc",clarity:"clar",clj:"clj",clojure:"clj","closure-templates":"soy",cmake:"cmake",cmd:"cmd",cobol:"cob",codeowners:"CODEOWNERS",codeql:"ql",coffee:"coffee",coffeescript:"coffee","common-lisp":"lisp",console:"sh",coq:"v",cpp:"cpp",cql:"cql",crystal:"cr",cs:"cs",csharp:"cs",css:"css",csv:"csv",cue:"cue",cypher:"cql",d:"d",dart:"dart",dax:"dax",desktop:"desktop",diff:"diff",docker:"dockerfile",dockerfile:"dockerfile",dotenv:"env","dream-maker":"dm",edge:"edge",elisp:"el",elixir:"ex",elm:"elm","emacs-lisp":"el",erb:"erb",erl:"erl",erlang:"erl",f:"f","f#":"fs",f03:"f03",f08:"f08",f18:"f18",f77:"f77",f90:"f90",f95:"f95",fennel:"fnl",fish:"fish",fluent:"ftl",for:"for","fortran-fixed-form":"f","fortran-free-form":"f90",fs:"fs",fsharp:"fs",fsl:"fsl",ftl:"ftl",gdresource:"tres",gdscript:"gd",gdshader:"gdshader",genie:"gs",gherkin:"feature","git-commit":"gitcommit","git-rebase":"gitrebase",gjs:"js",gleam:"gleam","glimmer-js":"js","glimmer-ts":"ts",glsl:"glsl",gnuplot:"plt",go:"go",gql:"gql",graphql:"graphql",groovy:"groovy",gts:"gts",hack:"hack",haml:"haml",handlebars:"hbs",haskell:"hs",haxe:"hx",hbs:"hbs",hcl:"hcl",hjson:"hjson",hlsl:"hlsl",hs:"hs",html:"html","html-derivative":"html",http:"http",hxml:"hxml",hy:"hy",imba:"imba",ini:"ini",jade:"jade",java:"java",javascript:"js",jinja:"jinja",jison:"jison",jl:"jl",js:"js",json:"json",json5:"json5",jsonc:"jsonc",jsonl:"jsonl",jsonnet:"jsonnet",jssm:"jssm",jsx:"jsx",julia:"jl",kotlin:"kt",kql:"kql",kt:"kt",kts:"kts",kusto:"kql",latex:"tex",lean:"lean",lean4:"lean",less:"less",liquid:"liquid",lisp:"lisp",lit:"lit",llvm:"ll",log:"log",logo:"logo",lua:"lua",luau:"luau",make:"mak",makefile:"mak",markdown:"md",marko:"marko",matlab:"m",md:"md",mdc:"mdc",mdx:"mdx",mediawiki:"wiki",mermaid:"mmd",mips:"s",mipsasm:"s",mmd:"mmd",mojo:"mojo",move:"move",nar:"nar",narrat:"narrat",nextflow:"nf",nf:"nf",nginx:"conf",nim:"nim",nix:"nix",nu:"nu",nushell:"nu",objc:"m","objective-c":"m","objective-cpp":"mm",ocaml:"ml",pascal:"pas",perl:"pl",perl6:"p6",php:"php",plsql:"pls",po:"po",polar:"polar",postcss:"pcss",pot:"pot",potx:"potx",powerquery:"pq",powershell:"ps1",prisma:"prisma",prolog:"pl",properties:"properties",proto:"proto",protobuf:"proto",ps:"ps",ps1:"ps1",pug:"pug",puppet:"pp",purescript:"purs",py:"py",python:"py",ql:"ql",qml:"qml",qmldir:"qmldir",qss:"qss",r:"r",racket:"rkt",raku:"raku",razor:"cshtml",rb:"rb",reg:"reg",regex:"regex",regexp:"regexp",rel:"rel",riscv:"s",rs:"rs",rst:"rst",ruby:"rb",rust:"rs",sas:"sas",sass:"sass",scala:"scala",scheme:"scm",scss:"scss",sdbl:"sdbl",sh:"sh",shader:"shader",shaderlab:"shader",shell:"sh",shellscript:"sh",shellsession:"sh",smalltalk:"st",solidity:"sol",soy:"soy",sparql:"rq",spl:"spl",splunk:"spl",sql:"sql","ssh-config":"config",stata:"do",styl:"styl",stylus:"styl",svelte:"svelte",swift:"swift","system-verilog":"sv",systemd:"service",talon:"talon",talonscript:"talon",tasl:"tasl",tcl:"tcl",templ:"templ",terraform:"tf",tex:"tex",tf:"tf",tfvars:"tfvars",toml:"toml",ts:"ts","ts-tags":"ts",tsp:"tsp",tsv:"tsv",tsx:"tsx",turtle:"ttl",twig:"twig",typ:"typ",typescript:"ts",typespec:"tsp",typst:"typ",v:"v",vala:"vala",vb:"vb",verilog:"v",vhdl:"vhdl",vim:"vim",viml:"vim",vimscript:"vim",vue:"vue","vue-html":"html","vue-vine":"vine",vy:"vy",vyper:"vy",wasm:"wasm",wenyan:"wy",wgsl:"wgsl",wiki:"wiki",wikitext:"wiki",wit:"wit",wl:"wl",wolfram:"wl",xml:"xml",xsl:"xsl",yaml:"yaml",yml:"yml",zenscript:"zs",zig:"zig",zsh:"zsh",\u6587\u8A00:"wy"},wt=({onDownload:e,onError:t,language:n,children:o,className:r,code:s,...i})=>{let a=k(),{code:l}=Ke(),{isAnimating:d}=useContext(B),c=O(),m=E(),u=s!=null?s:l,p=`file.${n&&n in xn?xn[n]:"txt"}`,h="text/plain",b=()=>{try{X(p,u,h),e==null||e();}catch(g){t==null||t(g);}};return jsx("button",{className:a("cursor-pointer rounded-md p-1.5 text-neutral-500 transition-colors hover:bg-black/5 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50 dark:text-muted-foreground dark:hover:bg-white/10",r),"data-markup":"code-block-download-button",disabled:d,onClick:b,title:c.downloadFile,type:"button",...i,children:o!=null?o:jsx(m.DownloadIcon,{size:14})})};var Je=()=>{let{Loader2Icon:e}=E(),t=k();return jsxs("div",{className:t("w-full divide-y divide-border overflow-hidden rounded-xl border border-border"),children:[jsx("div",{className:t("h-[46px] w-full bg-muted/80")}),jsx("div",{className:t("flex w-full items-center justify-center p-4"),children:jsx(e,{className:t("size-4 animate-spin")})})]})};var $s=/\.[^/.]+$/,Sn=({node:e,className:t,src:n,alt:o,onLoad:r,onError:s,...i})=>{let{DownloadIcon:a}=E(),l=k(),d=useRef(null),[c,m]=useState(false),[u,f]=useState(false),p=O(),h=i.width!=null||i.height!=null,b=(c||h)&&!u,g=u&&!h;useEffect(()=>{let v=d.current;if(v!=null&&v.complete){let x=v.naturalWidth>0;m(x),f(!x);}},[]);let y=useCallback(v=>{m(true),f(false),r==null||r(v);},[r]),w=useCallback(v=>{m(false),f(true),s==null||s(v);},[s]),M=async()=>{if(!(typeof n!="string"||!n))try{let x=await(await fetch(n)).blob(),A=new URL(n,window.location.origin).pathname.split("/").pop()||"",q=A.split(".").pop(),Z=A.includes(".")&&q!==void 0&&q.length<=4,F="";if(Z)F=A;else {let _=x.type,z="png";_.includes("jpeg")||_.includes("jpg")?z="jpg":_.includes("png")?z="png":_.includes("svg")?z="svg":_.includes("gif")?z="gif":_.includes("webp")&&(z="webp"),F=`${(o||A||"image").replace($s,"")}.${z}`;}X(F,x,x.type);}catch(v){window.open(n,"_blank");}};return typeof n!="string"||!n?null:jsxs("div",{className:l("group relative my-4 inline-block"),"data-markup":"image-wrapper",children:[jsx("img",{alt:o,className:l("max-w-full rounded-lg",g&&"hidden",t),"data-markup":"image",onError:w,onLoad:y,ref:d,src:n,...i}),g&&jsx("span",{className:l("text-muted-foreground text-xs italic"),"data-markup":"image-fallback",children:p.imageNotAvailable}),jsx("div",{className:l("pointer-events-none absolute inset-0 hidden rounded-lg bg-black/10 group-hover:block")}),b&&jsx("button",{className:l("absolute right-2 bottom-2 flex h-8 w-8 cursor-pointer items-center justify-center rounded-md border border-border bg-background/90 shadow-sm backdrop-blur-sm transition-all duration-200 hover:bg-background","opacity-0 group-hover:opacity-100"),onClick:M,title:p.downloadImage,type:"button",children:jsx(a,{size:14})})]})};var Ae=0,he=()=>{Ae+=1,Ae===1&&(document.body.style.overflow="hidden");},be=()=>{Ae=Math.max(0,Ae-1),Ae===0&&(document.body.style.overflow="");};var An=({url:e,isOpen:t,onClose:n,onConfirm:o})=>{let{CheckIcon:r,CopyIcon:s,ExternalLinkIcon:i,XIcon:a}=E(),l=k(),[d,c]=useState(false),m=O(),u=useCallback(async()=>{try{await navigator.clipboard.writeText(e),c(!0),setTimeout(()=>c(!1),2e3);}catch(p){}},[e]),f=useCallback(()=>{o(),n();},[o,n]);return useEffect(()=>{if(t){he();let p=h=>{h.key==="Escape"&&n();};return document.addEventListener("keydown",p),()=>{document.removeEventListener("keydown",p),be();}}},[t,n]),t?jsx("div",{className:l("fixed inset-0 z-50 flex items-center justify-center bg-background/50 backdrop-blur-sm"),"data-markup":"link-safety-modal",onClick:n,onKeyDown:p=>{p.key==="Escape"&&n();},role:"button",tabIndex:0,children:jsxs("div",{className:l("relative mx-4 flex w-full max-w-md flex-col gap-4 rounded-xl border bg-background p-6 shadow-lg"),onClick:p=>p.stopPropagation(),onKeyDown:p=>p.stopPropagation(),role:"presentation",children:[jsx("button",{className:l("absolute top-4 right-4 rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:n,title:m.close,type:"button",children:jsx(a,{size:16})}),jsxs("div",{className:l("flex flex-col gap-2"),children:[jsxs("div",{className:l("flex items-center gap-2 font-semibold text-lg"),children:[jsx(i,{size:20}),jsx("span",{children:m.openExternalLink})]}),jsx("p",{className:l("text-muted-foreground text-sm"),children:m.externalLinkWarning})]}),jsx("div",{className:l("break-all rounded-md bg-muted p-3 font-mono text-sm",e.length>100&&"max-h-32 overflow-y-auto"),children:e}),jsxs("div",{className:l("flex gap-2"),children:[jsx("button",{className:l("flex flex-1 items-center justify-center gap-2 rounded-md border bg-background px-4 py-2 font-medium text-sm transition-all hover:bg-muted"),onClick:u,type:"button",children:d?jsxs(Fragment,{children:[jsx(r,{size:14}),jsx("span",{children:m.copied})]}):jsxs(Fragment,{children:[jsx(s,{size:14}),jsx("span",{children:m.copyLink})]})}),jsxs("button",{className:l("flex flex-1 items-center justify-center gap-2 rounded-md bg-primary px-4 py-2 font-medium text-primary-foreground text-sm transition-all hover:bg-primary/90"),onClick:f,type:"button",children:[jsx(i,{size:14}),jsx("span",{children:m.openLink})]})]})]})}):null};var Ye=createContext(null),It=()=>useContext(Ye),Nc=()=>{var t;let e=It();return (t=e==null?void 0:e.code)!=null?t:null},ke=()=>{var t;let e=It();return (t=e==null?void 0:e.mermaid)!=null?t:null};var Hn=e=>{var n;let t=It();return t!=null&&t.renderers&&e&&(n=t.renderers.find(o=>Array.isArray(o.language)?o.language.includes(e):o.language===e))!=null?n:null};var Dn=(e,t)=>{var o;let n=(o=void 0)!=null?o:5;return new Promise((r,s)=>{let i="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(e))),a=new Image;a.crossOrigin="anonymous",a.onload=()=>{let l=document.createElement("canvas"),d=a.width*n,c=a.height*n;l.width=d,l.height=c;let m=l.getContext("2d");if(!m){s(new Error("Failed to create 2D canvas context for PNG export"));return}m.drawImage(a,0,0,d,c),l.toBlob(u=>{if(!u){s(new Error("Failed to create PNG blob"));return}r(u);},"image/png");},a.onerror=()=>s(new Error("Failed to load SVG image")),a.src=i;})};var _n=({chart:e,children:t,className:n,onDownload:o,config:r,onError:s})=>{let i=k(),[a,l]=useState(false),d=useRef(null),{isAnimating:c}=useContext(B),m=E(),u=ke(),f=O(),p=async h=>{try{if(h==="mmd"){X("diagram.mmd",e,"text/plain"),l(!1),o==null||o(h);return}if(!u){s==null||s(new Error("Mermaid plugin not available"));return}let b=u.getMermaid(r),g=e.split("").reduce((M,v)=>(M<<5)-M+v.charCodeAt(0)|0,0),y=`mermaid-${Math.abs(g)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:w}=await b.render(y,e);if(!w){s==null||s(new Error("SVG not found. Please wait for the diagram to render."));return}if(h==="svg"){X("diagram.svg",w,"image/svg+xml"),l(!1),o==null||o(h);return}if(h==="png"){let M=await Dn(w);X("diagram.png",M,"image/png"),o==null||o(h),l(!1);return}}catch(b){s==null||s(b);}};return useEffect(()=>{let h=b=>{let g=b.composedPath();d.current&&!g.includes(d.current)&&l(false);};return document.addEventListener("mousedown",h),()=>{document.removeEventListener("mousedown",h);}},[]),jsxs("div",{className:i("relative"),ref:d,children:[jsx("button",{className:i("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",n),disabled:c,onClick:()=>l(!a),title:f.downloadDiagram,type:"button",children:t!=null?t:jsx(m.DownloadIcon,{size:14})}),a?jsxs("div",{className:i("absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg"),children:[jsx("button",{className:i("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>p("svg"),title:f.downloadDiagramAsSvg,type:"button",children:f.mermaidFormatSvg}),jsx("button",{className:i("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>p("png"),title:f.downloadDiagramAsPng,type:"button",children:f.mermaidFormatPng}),jsx("button",{className:i("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>p("mmd"),title:f.downloadDiagramAsMmd,type:"button",children:f.mermaidFormatMmd})]}):null]})};var Fn=({chart:e,config:t,onFullscreen:n,onExit:o,className:r,...s})=>{let{Maximize2Icon:i,XIcon:a}=E(),l=k(),[d,c]=useState(false),{isAnimating:m,controls:u}=useContext(B),f=O(),p=(()=>{if(typeof u=="boolean")return u;let b=u.mermaid;return b===false?false:b===true||b===void 0?true:b.panZoom!==false})(),h=()=>{c(!d);};return useEffect(()=>{if(d){he();let b=g=>{g.key==="Escape"&&c(false);};return document.addEventListener("keydown",b),()=>{document.removeEventListener("keydown",b),be();}}},[d]),useEffect(()=>{d?n==null||n():o&&o();},[d,n,o]),jsxs(Fragment,{children:[jsx("button",{className:l("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),disabled:m,onClick:h,title:f.viewFullscreen,type:"button",...s,children:jsx(i,{size:14})}),d?createPortal(jsxs("div",{className:l("fixed inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-sm"),onClick:h,onKeyDown:b=>{b.key==="Escape"&&h();},role:"button",tabIndex:0,children:[jsx("button",{className:l("absolute top-4 right-4 z-10 rounded-md p-2 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:h,title:f.exitFullscreen,type:"button",children:jsx(a,{size:20})}),jsx("div",{className:l("flex size-full items-center justify-center p-4"),onClick:b=>b.stopPropagation(),onKeyDown:b=>b.stopPropagation(),role:"presentation",children:jsx(Wn,{chart:e,className:l("size-full [&_svg]:h-auto [&_svg]:w-auto"),config:t,fullscreen:true,showControls:p})})]}),document.body):null]})};var Ce=e=>{var n;let t=e==null?void 0:e.closest('[data-markup="table-wrapper"], [data-markup="table-fullscreen"]');return (n=t==null?void 0:t.querySelector("table"))!=null?n:null},de=e=>{var s,i;let t=[],n=[],o=e.querySelectorAll("thead th");for(let a of o)t.push(((s=a.textContent)==null?void 0:s.trim())||"");let r=e.querySelectorAll("tbody tr");for(let a of r){let l=[],d=a.querySelectorAll("td");for(let c of d)l.push(((i=c.textContent)==null?void 0:i.trim())||"");n.push(l);}return {headers:t,rows:n}},ue=e=>{let{headers:t,rows:n}=e,o=a=>{let l=false,d=false;for(let c of a){if(c==='"'){l=true,d=true;break}(c===","||c===`
6
+ `)&&(l=true);}return l?d?`"${a.replace(/"/g,'""')}"`:`"${a}"`:a},r=t.length>0?n.length+1:n.length,s=new Array(r),i=0;t.length>0&&(s[i]=t.map(o).join(","),i+=1);for(let a of n)s[i]=a.map(o).join(","),i+=1;return s.join(`
7
+ `)},Pt=e=>{let{headers:t,rows:n}=e,o=a=>{let l=false;for(let c of a)if(c===" "||c===`
8
+ `||c==="\r"){l=true;break}if(!l)return a;let d=[];for(let c of a)c===" "?d.push("\\t"):c===`
9
+ `?d.push("\\n"):c==="\r"?d.push("\\r"):d.push(c);return d.join("")},r=t.length>0?n.length+1:n.length,s=new Array(r),i=0;t.length>0&&(s[i]=t.map(o).join(" "),i+=1);for(let a of n)s[i]=a.map(o).join(" "),i+=1;return s.join(`
10
+ `)},Qe=e=>{let t=false;for(let o of e)if(o==="\\"||o==="|"){t=true;break}if(!t)return e;let n=[];for(let o of e)o==="\\"?n.push("\\\\"):o==="|"?n.push("\\|"):n.push(o);return n.join("")},se=e=>{let{headers:t,rows:n}=e;if(t.length===0)return "";let o=new Array(n.length+2),r=0,s=t.map(a=>Qe(a));o[r]=`| ${s.join(" | ")} |`,r+=1;let i=new Array(t.length);for(let a=0;a<t.length;a+=1)i[a]="---";o[r]=`| ${i.join(" | ")} |`,r+=1;for(let a of n)if(a.length<t.length){let l=new Array(t.length);for(let d=0;d<t.length;d+=1)l[d]=d<a.length?Qe(a[d]):"";o[r]=`| ${l.join(" | ")} |`,r+=1;}else {let l=a.map(d=>Qe(d));o[r]=`| ${l.join(" | ")} |`,r+=1;}return o.join(`
11
+ `)};var De=({children:e,className:t,onCopy:n,onError:o,timeout:r=2e3})=>{let s=k(),[i,a]=useState(false),l=useRef(0),{isAnimating:d}=useContext(B),c=O(),m=E(),u=i?m.CheckIcon:m.CopyIcon,f=async p=>{if(typeof window=="undefined"||!(navigator!=null&&navigator.clipboard)){o==null||o(new Error("Clipboard API not available"));return}try{let h=Ce(p.currentTarget);if(!h){o==null||o(new Error("Table not found"));return}let b=de(h),g=se(b),y=navigator.clipboard;if(y.writeText)await y.writeText(g);else if(y.write&&typeof ClipboardItem!="undefined"){let w=new ClipboardItem({"text/plain":new Blob([g],{type:"text/plain"})});await y.write([w]);}else {o==null||o(new Error("Clipboard API not available"));return}a(!0),n==null||n("md"),l.current=window.setTimeout(()=>a(!1),r);}catch(h){o==null||o(h);}};return useEffect(()=>()=>{window.clearTimeout(l.current);},[]),jsx("button",{className:s("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:d,onClick:f,title:c.copyTableAsMarkdown,type:"button",children:e!=null?e:jsx(u,{height:14,width:14})})},Qs=({children:e,className:t,onCopy:n,onError:o,timeout:r=2e3})=>{let s=k(),[i,a]=useState(false),[l,d]=useState(false),c=useRef(null),m=useRef(0),{isAnimating:u}=useContext(B),f=O(),p=async g=>{var y;if(typeof window=="undefined"||!((y=navigator==null?void 0:navigator.clipboard)!=null&&y.write)){o==null||o(new Error("Clipboard API not available"));return}try{let w=Ce(c.current);if(!w){o==null||o(new Error("Table not found"));return}let M=de(w),H=({csv:ue,tsv:Pt,md:se}[g]||se)(M),A=new ClipboardItem({"text/plain":new Blob([H],{type:"text/plain"}),"text/html":new Blob([w.outerHTML],{type:"text/html"})});await navigator.clipboard.write([A]),d(!0),a(!1),n==null||n(g),m.current=window.setTimeout(()=>d(!1),r);}catch(w){o==null||o(w);}};useEffect(()=>{let g=y=>{let w=y.composedPath();c.current&&!w.includes(c.current)&&a(false);};return document.addEventListener("mousedown",g),()=>{document.removeEventListener("mousedown",g),window.clearTimeout(m.current);}},[]);let h=E(),b=l?h.CheckIcon:h.CopyIcon;return jsxs("div",{className:s("relative"),ref:c,children:[jsx("button",{className:s("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:u,onClick:()=>a(!i),title:f.copyTable,type:"button",children:e!=null?e:jsx(b,{height:14,width:14})}),i?jsxs("div",{className:s("absolute top-full right-0 z-20 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg"),children:[jsx("button",{className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>p("md"),title:f.copyTableAsMarkdown,type:"button",children:f.tableFormatMarkdown}),jsx("button",{className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>p("csv"),title:f.copyTableAsCsv,type:"button",children:f.tableFormatCsv}),jsx("button",{className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>p("tsv"),title:f.copyTableAsTsv,type:"button",children:f.tableFormatTsv})]}):null]})};var oi=({children:e,className:t,onDownload:n,onError:o,format:r="csv",filename:s})=>{let i=k(),{isAnimating:a}=useContext(B),l=O(),d=E(),c=m=>{try{let u=Ce(m.currentTarget);if(!u){o==null||o(new Error("Table not found"));return}let f=de(u),p="",h="",b="";switch(r){case "csv":p=ue(f),h="text/csv",b="csv";break;case "markdown":p=se(f),h="text/markdown",b="md";break;default:p=ue(f),h="text/csv",b="csv";}X(`${s||"table"}.${b}`,p,h),n==null||n();}catch(u){o==null||o(u);}};return jsx("button",{className:i("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:a,onClick:c,title:r==="csv"?l.downloadTableAsCsv:l.downloadTableAsMarkdown,type:"button",children:e!=null?e:jsx(d.DownloadIcon,{size:14})})},Oe=({children:e,className:t,onDownload:n,onError:o})=>{let r=k(),[s,i]=useState(false),a=useRef(null),{isAnimating:l}=useContext(B),d=O(),c=E(),m=u=>{try{let f=Ce(a.current);if(!f){o==null||o(new Error("Table not found"));return}let p=de(f),h=u==="csv"?ue(p):se(p);X(`table.${u==="csv"?"csv":"md"}`,h,u==="csv"?"text/csv":"text/markdown"),i(!1),n==null||n(u);}catch(f){o==null||o(f);}};return useEffect(()=>{let u=f=>{let p=f.composedPath();a.current&&!p.includes(a.current)&&i(false);};return document.addEventListener("mousedown",u),()=>{document.removeEventListener("mousedown",u);}},[]),jsxs("div",{className:r("relative"),ref:a,children:[jsx("button",{className:r("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:l,onClick:()=>i(!s),title:d.downloadTable,type:"button",children:e!=null?e:jsx(c.DownloadIcon,{size:14})}),s?jsxs("div",{className:r("absolute top-full right-0 z-20 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg"),children:[jsx("button",{className:r("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>m("csv"),title:d.downloadTableAsCsv,type:"button",children:d.tableFormatCsv}),jsx("button",{className:r("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>m("markdown"),title:d.downloadTableAsMarkdown,type:"button",children:d.tableFormatMarkdown})]}):null]})};var Zn=({children:e,className:t,showCopy:n=true,showDownload:o=true})=>{let{Maximize2Icon:r,XIcon:s}=E(),i=k(),[a,l]=useState(false),{isAnimating:d}=useContext(B),c=O(),m=()=>{l(true);},u=()=>{l(false);};return useEffect(()=>{if(a){he();let f=p=>{p.key==="Escape"&&l(false);};return document.addEventListener("keydown",f),()=>{document.removeEventListener("keydown",f),be();}}},[a]),jsxs(Fragment,{children:[jsx("button",{className:i("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:d,onClick:m,title:c.viewFullscreen,type:"button",children:jsx(r,{size:14})}),a?createPortal(jsx("div",{"aria-label":c.viewFullscreen,"aria-modal":"true",className:i("fixed inset-0 z-50 flex flex-col bg-background"),"data-markup":"table-fullscreen",onClick:u,onKeyDown:f=>{f.key==="Escape"&&u();},role:"dialog",children:jsxs("div",{className:i("flex h-full flex-col"),onClick:f=>f.stopPropagation(),onKeyDown:f=>f.stopPropagation(),role:"presentation",children:[jsxs("div",{className:i("flex items-center justify-end gap-1 p-4"),children:[n?jsx(De,{}):null,o?jsx(Oe,{}):null,jsx("button",{className:i("rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:u,title:c.exitFullscreen,type:"button",children:jsx(s,{size:20})})]}),jsx("div",{className:i("flex-1 overflow-auto p-4 pt-0 [&_thead]:sticky [&_thead]:top-0 [&_thead]:z-10"),children:jsx("table",{className:i("w-full border-collapse border border-border"),"data-markup":"table",children:e})})]})}),document.body):null]})};var Gn=({children:e,className:t,showControls:n,showCopy:o=true,showDownload:r=true,showFullscreen:s=true,...i})=>{let a=k(),l=n&&o,d=n&&r,c=n&&s,m=l||d||c,u=a("rounded-md bg-transparent p-1.5 text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50");return jsxs("div",{className:a("group/markup-table relative my-4",m?"[&_thead_th:last-child]:pr-10":null),"data-markup":"table-wrapper",children:[m?jsxs("div",{className:a("pointer-events-none absolute top-1 right-0 z-10 flex items-center gap-1 opacity-0 transition-opacity group-focus-within/markup-table:pointer-events-auto group-focus-within/markup-table:opacity-100 group-hover/markup-table:pointer-events-auto group-hover/markup-table:opacity-100"),"data-markup":"table-actions",children:[l?jsx(De,{className:u}):null,d?jsx(Oe,{className:u}):null,c?jsx(Zn,{className:u,showCopy:l,showDownload:d,children:e}):null]}):null,jsx("div",{className:a("overflow-x-auto"),children:jsx("table",{className:a("w-full border-collapse text-sm",t),"data-markup":"table",...i,children:e})})]})};var mi=/startLine=(\d+)/,pi=/\bnoLineNumbers\b/,fi=lazy(()=>import('./mermaid-EHIBIOVN.js').then(e=>({default:e.Mermaid}))),gi=/language-([^\s]+)/,hi=/^(?:https?:)?\/\//i;function bi(e,t){if(!(e!=null&&e.position||t!=null&&t.position))return true;if(!(e!=null&&e.position&&(t!=null&&t.position)))return false;let n=e.position.start,o=t.position.start,r=e.position.end,s=t.position.end;return (n==null?void 0:n.line)===(o==null?void 0:o.line)&&(n==null?void 0:n.column)===(o==null?void 0:o.column)&&(r==null?void 0:r.line)===(s==null?void 0:s.line)&&(r==null?void 0:r.column)===(s==null?void 0:s.column)}function S(e,t){return e.className===t.className&&e.children===t.children&&bi(e.node,t.node)}var Rt=(e,t)=>typeof e=="boolean"?e:e[t]!==false,Nt=(e,t)=>{if(typeof e=="boolean")return t==="copy"?e:false;let n=e.table;return n===false?false:n===true||n===void 0?t==="copy":t==="copy"?n.copy!==false:n[t]===true},Yn=(e,t)=>{if(typeof e=="boolean")return t==="copy"?e:false;let n=e.code;return n===false?false:n===true||n===void 0?t==="copy":t==="copy"?n.copy!==false:n.download===true},et=(e,t)=>{if(typeof e=="boolean")return e;let n=e.mermaid;return n===false?false:n===true||n===void 0?true:n[t]!==false},Et=memo(({children:e,className:t,node:n,...o})=>{let r=k();return jsx("ol",{className:r("list-inside list-decimal whitespace-normal [li_&]:pl-6",t),"data-markup":"ordered-list",...o,children:e})},(e,t)=>S(e,t));Et.displayName="MarkdownOl";var Qn=memo(({children:e,className:t,node:n,...o})=>{let r=k();return jsx("li",{className:r("py-0.75 [&>p]:inline",t),"data-markup":"list-item",...o,children:e})},(e,t)=>S(e,t));Qn.displayName="MarkdownLi";var eo=memo(({children:e,className:t,node:n,...o})=>{let r=k();return jsx("ul",{className:r("list-inside list-disc whitespace-normal [li_&]:pl-6",t),"data-markup":"unordered-list",...o,children:e})},(e,t)=>S(e,t));eo.displayName="MarkdownUl";var to=memo(({className:e,node:t,...n})=>{let o=k();return jsx("hr",{className:o("my-6 border-border",e),"data-markup":"horizontal-rule",...n})},(e,t)=>S(e,t));to.displayName="MarkdownHr";var no=memo(({children:e,className:t,node:n,...o})=>{let r=k();return jsx("span",{className:r("font-semibold",t),"data-markup":"strong",...o,children:e})},(e,t)=>S(e,t));no.displayName="MarkdownStrong";var ki=({children:e,className:t,href:n,node:o,...r})=>{let s=k(),{linkSafety:i}=useContext(B),[a,l]=useState(false),d=n==="markup:incomplete-link",c="wrap-anywhere font-normal text-inherit underline decoration-current/40 decoration-dotted underline-offset-4 transition-colors hover:text-blue-600 hover:decoration-current dark:hover:text-blue-400",m=n&&hi.test(n)?jsx("svg",{"aria-hidden":"true",className:s("ml-0.5 inline-block h-[0.7em] w-[0.7em] align-baseline"),"data-markup":"link-icon",fill:"none",focusable:"false",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.75,viewBox:"0 0 16 16",children:jsx("path",{d:"M4 12 12 4M4 4h8v8"})}):null,u=useCallback(async b=>{if(!(!(i!=null&&i.enabled&&n)||d)){if(b.preventDefault(),i.onLinkCheck&&await i.onLinkCheck(n)){window.open(n,"_blank","noreferrer");return}l(true);}},[i,n,d]),f=useCallback(()=>{n&&window.open(n,"_blank","noreferrer");},[n]),p=useCallback(()=>{l(false);},[]),h={url:n!=null?n:"",isOpen:a,onClose:p,onConfirm:f};return i!=null&&i.enabled&&n?jsxs(Fragment,{children:[jsxs("button",{className:s(c,"appearance-none text-left",t),"data-incomplete":d,"data-markup":"link",onClick:u,type:"button",children:[e,m]}),i.renderModal?i.renderModal(h):jsx(An,{...h})]}):jsxs("a",{className:s(c,t),"data-incomplete":d,"data-markup":"link",href:n,rel:"noreferrer",target:"_blank",...r,children:[e,m]})},oo=memo(ki,(e,t)=>S(e,t)&&e.href===t.href);oo.displayName="MarkdownA";var ro=memo(({children:e,className:t,node:n,...o})=>{let r=k();return jsx("h1",{className:r("mt-4 mb-1 font-semibold text-3xl",t),"data-markup":"heading-1",...o,children:e})},(e,t)=>S(e,t));ro.displayName="MarkdownH1";var so=memo(({children:e,className:t,node:n,...o})=>{let r=k();return jsx("h2",{className:r("mt-4 mb-1 font-semibold text-xl",t),"data-markup":"heading-2",...o,children:e})},(e,t)=>S(e,t));so.displayName="MarkdownH2";var io=memo(({children:e,className:t,node:n,...o})=>{let r=k();return jsx("h3",{className:r("mt-4 mb-1 font-semibold text-lg",t),"data-markup":"heading-3",...o,children:e})},(e,t)=>S(e,t));io.displayName="MarkdownH3";var ao=memo(({children:e,className:t,node:n,...o})=>{let r=k();return jsx("h4",{className:r("mt-4 mb-1 font-semibold text-base",t),"data-markup":"heading-4",...o,children:e})},(e,t)=>S(e,t));ao.displayName="MarkdownH4";var lo=memo(({children:e,className:t,node:n,...o})=>{let r=k();return jsx("h5",{className:r("mt-1 mb-1 font-semibold text-base",t),"data-markup":"heading-5",...o,children:e})},(e,t)=>S(e,t));lo.displayName="MarkdownH5";var co=memo(({children:e,className:t,node:n,...o})=>{let r=k();return jsx("h6",{className:r("mt-6 mb-2 font-semibold text-sm",t),"data-markup":"heading-6",...o,children:e})},(e,t)=>S(e,t));co.displayName="MarkdownH6";var uo=memo(({children:e,className:t,node:n,...o})=>{let{controls:r}=useContext(B),s=Rt(r,"table"),i=Nt(r,"copy"),a=Nt(r,"download"),l=Nt(r,"fullscreen");return jsx(Gn,{className:t,showControls:s,showCopy:i,showDownload:a,showFullscreen:l,...o,children:e})},(e,t)=>S(e,t));uo.displayName="MarkdownTable";var mo=memo(({children:e,className:t,node:n,...o})=>{let r=k();return jsx("thead",{className:r("border-border border-b",t),"data-markup":"table-header",...o,children:e})},(e,t)=>S(e,t));mo.displayName="MarkdownThead";var po=memo(({children:e,className:t,node:n,...o})=>{let r=k();return jsx("tbody",{className:r("divide-y divide-border",t),"data-markup":"table-body",...o,children:e})},(e,t)=>S(e,t));po.displayName="MarkdownTbody";var fo=memo(({children:e,className:t,node:n,...o})=>{let r=k();return jsx("tr",{className:r("border-border",t),"data-markup":"table-row",...o,children:e})},(e,t)=>S(e,t));fo.displayName="MarkdownTr";var go=memo(({children:e,className:t,node:n,...o})=>{let r=k();return jsx("th",{className:r("first:!text-left whitespace-nowrap px-3 py-2 text-left font-semibold text-sm first:pl-0 last:pr-0",t),"data-markup":"table-header-cell",...o,children:e})},(e,t)=>S(e,t));go.displayName="MarkdownTh";var ho=memo(({children:e,className:t,node:n,...o})=>{let r=k();return jsx("td",{className:r("px-3 py-2 text-sm first:pl-0 last:pr-0",t),"data-markup":"table-cell",...o,children:e})},(e,t)=>S(e,t));ho.displayName="MarkdownTd";var bo=memo(({children:e,className:t,node:n,...o})=>{let r=k();return jsx("blockquote",{className:r("my-4 border-muted-foreground/30 border-l-4 pl-4",t),"data-markup":"blockquote",...o,children:e})},(e,t)=>S(e,t));bo.displayName="MarkdownBlockquote";var ko=memo(({children:e,className:t,node:n,...o})=>{let r=k();return jsx("sup",{className:r("text-sm",t),"data-markup":"superscript",...o,children:e})},(e,t)=>S(e,t));ko.displayName="MarkdownSup";var yo=memo(({children:e,className:t,node:n,...o})=>{let r=k();return jsx("sub",{className:r("text-sm",t),"data-markup":"subscript",...o,children:e})},(e,t)=>S(e,t));yo.displayName="MarkdownSub";var Co=memo(({children:e,className:t,node:n,...o})=>{if("data-footnotes"in o){let s=l=>{var u,f;if(!isValidElement(l))return false;let d=Array.isArray(l.props.children)?l.props.children:[l.props.children],c=false,m=false;for(let p of d)if(p){if(typeof p=="string")p.trim()!==""&&(c=true);else if(isValidElement(p))if(((u=p.props)==null?void 0:u["data-footnote-backref"])!==void 0)m=true;else {let h=Array.isArray(p.props.children)?p.props.children:[p.props.children];for(let b of h){if(typeof b=="string"&&b.trim()!==""){c=true;break}if(isValidElement(b)&&((f=b.props)==null?void 0:f["data-footnote-backref"])===void 0){c=true;break}}}}return m&&!c},i=Array.isArray(e)?e.map(l=>{if(!isValidElement(l))return l;if(l.type===Et){let c=(Array.isArray(l.props.children)?l.props.children:[l.props.children]).filter(m=>!s(m));return c.length===0?null:{...l,props:{...l.props,children:c}}}return l}):e;return (Array.isArray(i)?i.some(l=>l!==null):i!==null)?jsx("section",{className:t,...o,children:i}):null}return jsx("section",{className:t,...o,children:e})},(e,t)=>S(e,t));Co.displayName="MarkdownSection";var yi=({node:e,className:t,children:n,...o})=>{var q,Z;let r=k(),s=!("data-block"in o),{mermaid:i,controls:a,lineNumbers:l}=useContext(B),d=ke(),c=ft(),m=t==null?void 0:t.match(gi),u=(q=m==null?void 0:m.at(1))!=null?q:"",f=Hn(u);if(s)return jsx("code",{className:r("rounded bg-[#ececec] px-1.5 py-0.5 font-mono text-sm dark:bg-muted",t),"data-markup":"inline-code",...o,children:n});let p=(Z=e==null?void 0:e.properties)==null?void 0:Z.metastring,h=typeof p=="string"?p:void 0,b=h==null?void 0:h.match(mi),g=b?Number.parseInt(b[1],10):void 0,y=g!==void 0&&g>=1?g:void 0,M=!(h?pi.test(h):false)&&l!==false,v="";if(isValidElement(n)&&n.props&&typeof n.props=="object"&&"children"in n.props&&typeof n.props.children=="string"?v=n.props.children:typeof n=="string"&&(v=n),f){let F=f.component;return jsx(Suspense,{fallback:jsx(Je,{}),children:jsx(F,{code:v,isIncomplete:c,language:u,meta:h})})}if(u==="mermaid"&&d){let F=Rt(a,"mermaid"),_=et(a,"download"),z=et(a,"copy"),re=et(a,"fullscreen"),ne=et(a,"panZoom"),T=F&&(_||z||re);return jsx(Suspense,{fallback:jsx(Je,{}),children:jsxs("div",{className:r("group relative my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2",t),"data-markup":"mermaid-block",children:[jsx("div",{className:r("flex h-8 items-center text-muted-foreground text-xs"),children:jsx("span",{className:r("ml-1 font-mono lowercase"),children:"mermaid"})}),T?jsx("div",{className:r("pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end"),children:jsxs("div",{className:r("pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur"),"data-markup":"mermaid-block-actions",children:[_?jsx(_n,{chart:v,config:i==null?void 0:i.config}):null,z?jsx(Ge,{code:v}):null,re?jsx(Fn,{chart:v,config:i==null?void 0:i.config}):null]})}):null,jsx("div",{className:r("rounded-md border border-border bg-background"),children:jsx(fi,{chart:v,config:i==null?void 0:i.config,showControls:ne})})]})})}let x=Rt(a,"code"),H=Yn(a,"download"),A=Yn(a,"copy");return jsx(yt,{className:t,code:v,isIncomplete:c,language:u,lineNumbers:M,startLine:y,children:x?jsxs(Fragment,{children:[H?jsx(wt,{code:v,language:u}):null,A?jsx(Ge,{}):null]}):null})},wo=memo(yi,(e,t)=>S(e,t));wo.displayName="MarkdownCode";var vo=memo(Sn,(e,t)=>S(e,t));vo.displayName="MarkdownImg";var Io=memo(({children:e,node:t,...n})=>{let r=(Array.isArray(e)?e:[e]).filter(s=>s!=null&&s!=="");if(r.length===1&&isValidElement(r[0])){let s=r[0].props.node,i=s==null?void 0:s.tagName;if(i==="img")return jsx(Fragment,{children:e});if(i==="code")return "data-block"in r[0].props?jsx(Fragment,{children:e}):jsx("p",{"data-markup":"code-paragraph",...n,children:e})}return jsx("p",{...n,children:e})},(e,t)=>S(e,t));Io.displayName="MarkdownParagraph";var Po={ol:Et,li:Qn,ul:eo,hr:to,strong:no,a:oo,h1:ro,h2:so,h3:io,h4:ao,h5:lo,h6:co,table:uo,thead:mo,tbody:po,tr:fo,th:go,td:ho,blockquote:bo,code:wo,img:vo,pre:({children:e})=>isValidElement(e)?cloneElement(e,{"data-block":"true"}):e,sup:ko,sub:yo,p:Io,section:Co};var Ci=/[\u0590-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFF]/,wi=/\p{L}/u;function nt(e){let t=e.replace(/^#{1,6}\s+/gm,"").replace(/(\*{1,3}|_{1,3})/g,"").replace(/`[^`]*`/g,"").replace(/\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/^[\s>*\-+\d.]+/gm,"");for(let n of t){if(Ci.test(n))return "rtl";if(wi.test(n))return "ltr"}return "ltr"}var vi=/^[ \t]{0,3}(`{3,}|~{3,})/,Ii=/^\|?[ \t]*:?-{1,}:?[ \t]*(\|[ \t]*:?-{1,}:?[ \t]*)*\|?$/,Bt=e=>{let t=e.split(`
12
+ `),n=null,o=0;for(let r of t){let s=vi.exec(r);if(n===null){if(s){let i=s[1];n=i[0],o=i.length;}}else if(s){let i=s[1],a=i[0],l=i.length;a===n&&l>=o&&(n=null,o=0);}}return n!==null},To=e=>{let t=e.split(`
13
+ `);for(let n of t){let o=n.trim();if(o.length>0&&o.includes("|")&&Ii.test(o))return true}return false};var Mo=()=>e=>{visit(e,"html",(t,n,o)=>{!o||typeof n!="number"||(o.children[n]={type:"text",value:t.value});});};var Lo=[],No={allowDangerousHtml:true},ot=new WeakMap,Ht=class{constructor(){this.cache=new Map;this.keyCache=new WeakMap;this.maxSize=100;}generateCacheKey(t){let n=this.keyCache.get(t);if(n)return n;let o=t.rehypePlugins,r=t.remarkPlugins,s=t.remarkRehypeOptions;if(!(o||r||s)){let m="default";return this.keyCache.set(t,m),m}let i=m=>{if(!m||m.length===0)return "";let u="";for(let f=0;f<m.length;f+=1){let p=m[f];if(f>0&&(u+=","),Array.isArray(p)){let[h,b]=p;if(typeof h=="function"){let g=ot.get(h);g||(g=h.name,ot.set(h,g)),u+=g;}else u+=String(h);u+=":",u+=JSON.stringify(b);}else if(typeof p=="function"){let h=ot.get(p);h||(h=p.name,ot.set(p,h)),u+=h;}else u+=String(p);}return u},a=i(o),l=i(r),d=s?JSON.stringify(s):"",c=`${l}::${a}::${d}`;return this.keyCache.set(t,c),c}get(t){let n=this.generateCacheKey(t),o=this.cache.get(n);return o&&(this.cache.delete(n),this.cache.set(n,o)),o}set(t,n){let o=this.generateCacheKey(t);if(this.cache.size>=this.maxSize){let r=this.cache.keys().next().value;r&&this.cache.delete(r);}this.cache.set(o,n);}clear(){this.cache.clear();}},Ro=new Ht,Dt=e=>{let t=Bi(e),n=e.children||"",o=t.runSync(t.parse(n),n);return $i(o,e)},Bi=e=>{let t=Ro.get(e);if(t)return t;let n=Hi(e);return Ro.set(e,n),n},Ai=e=>e.some(t=>Array.isArray(t)?t[0]===xo:t===xo),Hi=e=>{let t=e.rehypePlugins||Lo,n=e.remarkPlugins||Lo,o=Ai(t)?n:[...n,Mo],r=e.remarkRehypeOptions?{...No,...e.remarkRehypeOptions}:No;return unified().use(Ni).use(o).use(Ri,r).use(t)},So=e=>e,Di=(e,t,n,o)=>{n?e.children.splice(t,1):e.children[t]={type:"text",value:o};},Oi=(e,t)=>{var n;for(let o in urlAttributes)if(Object.hasOwn(urlAttributes,o)&&Object.hasOwn(e.properties,o)){let r=e.properties[o],s=urlAttributes[o];(s===null||s.includes(e.tagName))&&(e.properties[o]=(n=t(String(r||""),o,e))!=null?n:void 0);}},_i=(e,t,n,o,r,s)=>{let i=false;return o?i=!o.includes(e.tagName):r&&(i=r.includes(e.tagName)),!i&&s&&typeof t=="number"&&(i=!s(e,t,n)),i},$i=(e,t)=>{let{allowElement:n,allowedElements:o,disallowedElements:r,skipHtml:s,unwrapDisallowed:i,urlTransform:a}=t;if(n||o||r||s||a){let d=a||So;visit(e,(c,m,u)=>{if(c.type==="raw"&&u&&typeof m=="number")return Di(u,m,s,c.value),m;if(c.type==="element"&&(Oi(c,d),_i(c,m,u,o,r,n)&&u&&typeof m=="number"))return i&&c.children?u.children.splice(m,1,...c.children):u.children.splice(m,1),m});}return toJsxRuntime(e,{Fragment:Fragment,components:t.components,ignoreInvalidStyle:true,jsx:jsx,jsxs:jsxs,passKeys:true,passNode:true})};var ji=/^(?: {0,3}> ?)*(?: {0,3}(?:[-+*]|\d+[.)]) +)?[ \t]*$/,Wi=/^<[A-Za-z/!]/,Ot,_t=[];function $e(e){if(e===Ot)return _t;let t=[];if(!(e.includes("\\(")||e.includes("\\[")))return Ot=e,_t=t,t;let n=-1,o="",r="",s=0,i=0;for(let a=0;a<e.length;a++){let l=e[a];if((l===`
14
+ `||l==="\r")&&(i=a+1),n!==-1){l==="\\"&&(e[a+1]===o&&(t.push({start:n,end:a+2,closed:true}),n=-1),a++);continue}if(l==="`"||l==="~"){let d=a+1;for(;e[d]===l;)d++;let c=d-a,m=ji.test(e.slice(i,a));if(r){if(l===r&&c>=s&&m){let u=e.indexOf(`
15
+ `,d);e.slice(d,u===-1?void 0:u).trim()||(r="");}}else if(c>=3&&m)r=l,s=c;else if(l==="`"){let u=Fi(e,d,c);if(u!==-1){a=u,i=e.lastIndexOf(`
16
+ `,a)+1;continue}}a=d-1;continue}if(!r){if(l==="$"){let d=Vi(e,a);if(d!==-1){a=d,i=e.lastIndexOf(`
17
+ `,a)+1;continue}}if(l==="<"&&Wi.test(e.slice(a,a+2))){a=zi(e,a),i=e.lastIndexOf(`
18
+ `,a)+1;continue}if(l==="]"&&e[a+1]==="("){a=Ui(e,a+2),i=e.lastIndexOf(`
19
+ `,a)+1;continue}l==="\\"&&((e[a+1]==="("||e[a+1]==="[")&&(n=a,o=e[a+1]==="("?")":"]"),a++);}}return n!==-1&&t.push({start:n,end:e.length,closed:false}),Ot=e,_t=t,t}function Fi(e,t,n){let o=t;for(;o<e.length;){let r=e.indexOf("`",o);if(r===-1)break;for(o=r+1;e[o]==="`";)o++;if(o-r===n)return o-1}return -1}function Vi(e,t){let n=t+1;for(;e[n]==="$";)n++;let o=n-t,r=n;for(;r<e.length;){let s=e.indexOf("$",r);if(s===-1)break;for(r=s+1;e[r]==="$";)r++;if(r-s===o)return r-1}return o>=2?e.length-1:-1}function zi(e,t){let n="";for(let o=t+1;o<e.length;o++){let r=e[o];if(n)r===n&&(n="");else if(r==='"'||r==="'")n=r;else if(r===">")return o}return e.length-1}function Ui(e,t){let n=1;for(let o=t;o<e.length;o++)if(e[o]==="\\")o++;else if(e[o]==="(")n++;else if(e[o]===")"&&--n===0)return o;return e.length-1}function P(e,t){let n=$e(e),o=0,r=n.length;for(;o<r;){let s=Math.floor((o+r)/2),i=n[s];if(t<i.start)r=s;else if(t>=i.end)o=s+1;else return true}return false}var qi=/\[\^[\w-]{1,200}\](?!:)/,Zi=/\[\^[\w-]{1,200}\]:/;var Xi=/<(\w+)[\s>]/,Gi=/\r\n?/g,$t=e=>qi.test(e)||Zi.test(e)||e.includes("]:"),Ji=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Eo=new Map,Bo=new Map,Yi=e=>{let t=e.toLowerCase(),n=Eo.get(t);if(n)return n;let o=new RegExp(`<${t}(?=[\\s>/])[^>]*>`,"gi");return Eo.set(t,o),o},Qi=e=>{let t=e.toLowerCase(),n=Bo.get(t);if(n)return n;let o=new RegExp(`</${t}(?=[\\s>])[^>]*>`,"gi");return Bo.set(t,o),o},Ao=(e,t)=>{if(Ji.has(t.toLowerCase()))return 0;let n=e.match(Yi(t));if(!n)return 0;let o=0;for(let r of n)r.trimEnd().endsWith("/>")||(o+=1);return o},Ho=(e,t)=>{let n=e.match(Qi(t));return n?n.length:0},ea=e=>{let t=0;for(let n=0;n<e.length-1;n+=1)e[n]==="$"&&e[n+1]==="$"&&(t+=1,n+=1);return t},Ie=e=>{if($t(e))return [e];let t=e.includes("\r")?e.replace(Gi,`
20
+ `):e,n=Lexer.lex(t,{gfm:true}),o=$e(t),r=0,s=0,i=[],a=[],l=false;for(let d of n){let c=d.raw,m=i.length,u=r;for(r+=c.length;s<o.length&&o[s].end<=u;)s++;let f=o[s];if(f&&f.start<u&&u<f.end&&m>0){i[m-1]+=c;continue}if(a.length>0){i[m-1]+=c;let p=a.at(-1),h=Ao(c,p),b=Ho(c,p);for(let g=0;g<h;g+=1)a.push(p);for(let g=0;g<b;g+=1)a.length>0&&a.at(-1)===p&&a.pop();continue}if(d.type==="html"&&d.block){let p=c.match(Xi);if(p){let h=p[1],b=Ao(c,h),g=Ho(c,h);b>g&&a.push(h);}}if(m>0&&!l){let p=i[m-1];if(ea(p)%2===1){i[m-1]=p+c;continue}}i.push(c),d.type!=="space"&&(l=d.type==="code");}return i};var ta=/\r\n?/g,na=/\S/;function Oo(e){var d;let t=(d=e.split)!=null?d:Ie,n,o="",r=0,s=[],i=false,a={blocks:[],parsedCharacters:0,reusedBlocks:0};function l(c){if(c===n)return a;if(n!==void 0&&c.startsWith(n)){let y=c.slice(n.length);n.endsWith("\r")&&y.startsWith(`
21
+ `)&&(y=y.slice(1)),o+=Do(y);}else o=Do(c),r=0,s=[],i=false;n=c;let m=o.slice(r);i||(i=$t(m));let u=0,f=y=>(u+=y.length,t(y));if(e.incremental===false||i)return r=0,s=[],a={blocks:f(e.prepare(c)),parsedCharacters:u,reusedBlocks:0},a;let p=f(m),h=p.map(y=>{let w=e.prepare(y);return w===y?[y]:f(w)}),b=h.flat();a={blocks:[...s,...b],parsedCharacters:u,reusedBlocks:s.length};let g=oa(p);if(g>0&&p.join("")===m){for(let y=0;y<g;y++)r+=p[y].length;s=[...s,...h.slice(0,g).flat()];}return a}return {update:l}}function Do(e){return e.includes("\r")?e.replace(ta,`
22
+ `):e}function oa(e){let t=0,n=e.length;for(;n>0&&(n--,!(na.test(e[n])&&(t++,t===2))););return n}var _o=(e,t)=>{if(!t.length)return e;let n=e;for(let o of t){let r=new RegExp(`(<${o}(?=[\\s>/])[^>]*>)([\\s\\S]*?)(</${o}\\s*>)`,"gi");n=n.replace(r,(s,i,a,l)=>{if(!a.includes(`
23
+
24
+ `))return i+a+l;let d=a.replace(/\n\n/g,`
25
+ <!---->
26
+ `),c=(d.startsWith(`
27
+ `)?"":`
28
+ `)+d+(d.endsWith(`
29
+ `)?"":`
30
+ `);return `${i}${c}${l}
31
+
32
+ `});}return n};var ra=/([\\`*_~[\]|])/g,sa=e=>e.replace(ra,"\\$1"),$o=(e,t)=>{if(!t.length)return e;let n=e;for(let o of t){let r=new RegExp(`(<${o}(?=[\\s>/])[^>]*>)([\\s\\S]*?)(</${o}\\s*>)`,"gi");n=n.replace(r,(s,i,a,l)=>{let d=sa(a).replace(/\n\n/g,"&#10;&#10;");return i+d+l});}return n};var jo=e=>e.type==="text"?e.value:"children"in e&&Array.isArray(e.children)?e.children.map(jo).join(""):"",Wo=e=>t=>{if(!e||e.length===0)return;let n=new Set(e.map(o=>o.toLowerCase()));visit(t,"element",o=>{if(n.has(o.tagName.toLowerCase())){let r=jo(o);o.children=r?[{type:"text",value:r}]:[];}});};var Fo=()=>e=>{visit(e,"code",t=>{var n,o;t.meta&&(t.data=(n=t.data)!=null?n:{},t.data.hProperties={...(o=t.data.hProperties)!=null?o:{},metastring:t.meta});});};var D=(e,t)=>{let n=false,o=false;for(let r=0;r<t;r+=1)if(!P(e,r)){if(e[r]==="\\"&&r+1<e.length&&e[r+1]==="`"){r+=1;continue}if(e.substring(r,r+3)==="```"){o=!o,r+=2;continue}!o&&e[r]==="`"&&(n=!n);}return n||o},la=(e,t)=>{let n=e.substring(t,t+3)==="```",o=t>0&&e.substring(t-1,t+2)==="```",r=t>1&&e.substring(t-2,t+1)==="```";return n||o||r},Vo=e=>{let t=0;for(let n=0;n<e.length;n+=1)if(!P(e,n)){if(e[n]==="\\"&&n+1<e.length&&e[n+1]==="`"){n+=1;continue}e[n]==="`"&&!la(e,n)&&(t+=1);}return t},Q=(e,t)=>{let n=false,o=false,r=-1;for(let s=0;s<e.length;s+=1)if(!P(e,s)){if(e[s]==="\\"&&s+1<e.length&&e[s+1]==="`"){s+=1;continue}if(e.substring(s,s+3)==="```"){o=!o,s+=2;continue}if(!o&&e[s]==="`")if(n){if(r<t&&t<s)return true;n=false,r=-1;}else n=true,r=s;}return false};var ca=/^(\s*(?:[-*+]|\d+[.)]) +)>(=?\s*[$]?\d)/gm,zo=e=>!e||typeof e!="string"||!e.includes(">")?e:e.replace(ca,(t,n,o,r)=>P(e,r)||D(e,r)?t:`${n}\\>${o}`);var Uo=/(\*\*)([^*]*\*?)$/,Ko=/(__)([^_]*?)$/,qo=/(\*\*\*)([^*]*?)$/,Zo=/(\*)([^*]*?)$/,Xo=/(_)([^_]*?)$/,Go=/(`)([^`]*?)$/,Jo=/(~~)([^~]*?)$/,ee=/^[\s_~*`]*$/,jt=/^[\s]*[-*+][\s]+$/,Yo=/[\p{L}\p{N}_]/u,Qo=/^```[^`\n]*```?$/,er=/^\*{4,}$/;var tr=/(__)([^_]+)_$/,nr=/(~~)([^~]+)~$/;var or=/~~/g;var te=e=>{if(!e)return false;let t=e.charCodeAt(0);return t>=48&&t<=57||t>=65&&t<=90||t>=97&&t<=122||t===95?true:Yo.test(e)};var rr=(e,t)=>{let n=1;for(let o=t-1;o>=0;o-=1)if(e[o]==="]")n+=1;else if(e[o]==="["&&(n-=1,n===0))return o;return -1},Wt=(e,t)=>{let n=1;for(let o=t+1;o<e.length;o+=1)if(e[o]==="[")n+=1;else if(e[o]==="]"&&(n-=1,n===0))return o;return -1},Pe=(e,t)=>{if(P(e,t))return true;let n=false,o=false;for(let r=0;r<e.length&&r<t;r+=1){if(e[r]==="\\"&&e[r+1]==="$"){r+=1;continue}e[r]==="$"&&(e[r+1]==="$"?(o=!o,r+=1,n=false):o||(n=!n));}return n||o},da=(e,t)=>{for(let n=t;n<e.length;n+=1){if(e[n]===")")return true;if(e[n]===`
33
+ `)return false}return false},rt=(e,t)=>{for(let n=t-1;n>=0;n-=1){if(e[n]===")")return false;if(e[n]==="(")return n>0&&e[n-1]==="]"?da(e,t):false;if(e[n]===`
34
+ `)return false}return false},sr=(e,t)=>{for(let n=t-1;n>=0;n-=1){if(e[n]===">")return false;if(e[n]==="<"){let o=n+1<e.length?e[n+1]:"";return o>="a"&&o<="z"||o>="A"&&o<="Z"||o==="/"}if(e[n]===`
35
+ `)return false}return false},st=(e,t,n)=>{let o=0;for(let l=t-1;l>=0;l-=1)if(e[l]===`
36
+ `){o=l+1;break}let r=e.length;for(let l=t;l<e.length;l+=1)if(e[l]===`
37
+ `){r=l;break}let s=e.substring(o,r),i=0,a=false;for(let l of s)if(l===n)i+=1;else if(l!==" "&&l!==" "){a=true;break}return i>=3&&!a};var ua=(e,t,n,o)=>n==="\\"||(e.includes("$")||e.includes("\\"))&&Pe(e,t)?true:n!=="*"&&o==="*"?(t<e.length-2?e[t+2]:"")!=="*":!!(n==="*"||n&&o&&te(n)&&te(o)||(!n||n===" "||n===" "||n===`
38
+ `)&&(!o||o===" "||o===" "||o===`
39
+ `)),ar=e=>{let t=0,n=false,o=e.length;for(let r=0;r<o;r+=1){if(P(e,r))continue;if(e[r]==="`"&&r+2<o&&e[r+1]==="`"&&e[r+2]==="`"){n=!n,r+=2;continue}if(n||e[r]!=="*")continue;let s=r>0?e[r-1]:"",i=r<o-1?e[r+1]:"";ua(e,r,s,i)||(t+=1);}return t},ma=(e,t,n,o)=>!!(n==="\\"||(e.includes("$")||e.includes("\\"))&&Pe(e,t)||rt(e,t)||sr(e,t)||n==="_"||o==="_"||n&&o&&te(n)&&te(o)),pa=e=>{let t=0,n=false,o=e.length;for(let r=0;r<o;r+=1){if(P(e,r))continue;if(e[r]==="`"&&r+2<o&&e[r+1]==="`"&&e[r+2]==="`"){n=!n,r+=2;continue}if(n||e[r]!=="_")continue;let s=r>0?e[r-1]:"",i=r<o-1?e[r+1]:"";ma(e,r,s,i)||(t+=1);}return t},fa=e=>{let t=0,n=0,o=false;for(let r=0;r<e.length;r+=1)if(!P(e,r)){if(e[r]==="`"&&r+2<e.length&&e[r+1]==="`"&&e[r+2]==="`"){n>=3&&(t+=Math.floor(n/3)),n=0,o=!o,r+=2;continue}o||(e[r]==="*"?n+=1:(n>=3&&(t+=Math.floor(n/3)),n=0));}return n>=3&&(t+=Math.floor(n/3)),t},Ft=e=>{let t=0,n=false;for(let o=0;o<e.length;o+=1)if(!P(e,o)){if(e[o]==="`"&&o+2<e.length&&e[o+1]==="`"&&e[o+2]==="`"){n=!n,o+=2;continue}n||e[o]==="*"&&o+1<e.length&&e[o+1]==="*"&&(t+=1,o+=1);}return t},ir=e=>{let t=0,n=false;for(let o=0;o<e.length;o+=1)if(!P(e,o)){if(e[o]==="`"&&o+2<e.length&&e[o+1]==="`"&&e[o+2]==="`"){n=!n,o+=2;continue}n||e[o]==="_"&&o+1<e.length&&e[o+1]==="_"&&(t+=1,o+=1);}return t},ga=(e,t,n)=>{if(!t||ee.test(t))return true;let r=e.substring(0,n).lastIndexOf(`
40
+ `),s=r===-1?0:r+1,i=e.substring(s,n);return jt.test(i)&&t.includes(`
41
+ `)?true:st(e,n,"*")},lr=e=>{let t=e.match(Uo);if(!t)return e;let n=t[2],o=e.lastIndexOf(t[1]);return P(e,o)||D(e,o)||Q(e,o)||ga(e,n,o)?e:Ft(e)%2===1?n.endsWith("*")?`${e}*`:`${e}**`:e},ha=(e,t,n)=>{if(!t||ee.test(t))return true;let r=e.substring(0,n).lastIndexOf(`
42
+ `),s=r===-1?0:r+1,i=e.substring(s,n);return jt.test(i)&&t.includes(`
43
+ `)?true:st(e,n,"_")},cr=e=>{let t=e.match(Ko);if(!t){let s=e.match(tr);if(s){let i=e.lastIndexOf(s[1]);if(!(P(e,i)||D(e,i)||Q(e,i))&&ir(e)%2===1)return `${e}_`}return e}let n=t[2],o=e.lastIndexOf(t[1]);return P(e,o)||D(e,o)||Q(e,o)||ha(e,n,o)?e:ir(e)%2===1?`${e}__`:e},ba=e=>{let t=false;for(let n=0;n<e.length;n+=1)if(!P(e,n)){if(e[n]==="`"&&n+2<e.length&&e[n+1]==="`"&&e[n+2]==="`"){t=!t,n+=2;continue}if(!t&&e[n]==="*"&&e[n-1]!=="*"&&e[n+1]!=="*"&&e[n-1]!=="\\"&&!Pe(e,n)){let o=n>0?e[n-1]:"",r=n<e.length-1?e[n+1]:"";if((!o||o===" "||o===" "||o===`
44
+ `)&&(!r||r===" "||r===" "||r===`
45
+ `)||o&&r&&te(o)&&te(r))continue;return n}}return -1},dr=e=>{if(!e.match(Zo))return e;let n=ba(e);if(n===-1||P(e,n)||D(e,n)||Q(e,n))return e;let o=e.substring(n+1);return !o||ee.test(o)?e:ar(e)%2===1?`${e}*`:e},ur=e=>{let t=false;for(let n=0;n<e.length;n+=1)if(!P(e,n)){if(e[n]==="`"&&n+2<e.length&&e[n+1]==="`"&&e[n+2]==="`"){t=!t,n+=2;continue}if(!t&&e[n]==="_"&&e[n-1]!=="_"&&e[n+1]!=="_"&&e[n-1]!=="\\"&&!Pe(e,n)&&!rt(e,n)){let o=n>0?e[n-1]:"",r=n<e.length-1?e[n+1]:"";if(o&&r&&te(o)&&te(r))continue;return n}}return -1},ka=e=>{let t=e.length;for(;t>0&&e[t-1]===`
46
+ `;)t-=1;if(t<e.length){let n=e.slice(0,t),o=e.slice(t);return `${n}_${o}`}return `${e}_`},ya=e=>{if(!e.endsWith("**"))return null;let t=e.slice(0,-2);if(Ft(t)%2!==1)return null;let o=t.indexOf("**"),r=ur(t);return o!==-1&&r!==-1&&o<r?`${t}_**`:null},mr=e=>{if(!e.match(Xo))return e;let n=ur(e);if(n===-1)return e;let o=e.substring(n+1);if(!o||ee.test(o)||P(e,n)||D(e,n)||Q(e,n))return e;if(pa(e)%2===1){let s=ya(e);return s!==null?s:ka(e)}return e},Ca=e=>{let t=Ft(e),n=ar(e);return t%2===0&&n%2===0},wa=(e,t,n)=>!t||ee.test(t)||P(e,n)||D(e,n)||Q(e,n)?true:st(e,n,"*"),pr=e=>{if(er.test(e))return e;let t=e.match(qo);if(!t)return e;let n=t[2],o=e.lastIndexOf(t[1]);return wa(e,n,o)?e:fa(e)%2===1?Ca(e)?e:`${e}***`:e};var va=/<[a-zA-Z/][^>]*$/,fr=e=>{let t=e.match(va);return !t||t.index===void 0||P(e,t.index)||D(e,t.index)?e:e.substring(0,t.index).trimEnd()};var Ia=e=>!e.match(Qo)||e.includes(`
47
+ `)?null:e.endsWith("``")&&!e.endsWith("```")?`${e}\``:e,Pa=e=>(e.match(/```/g)||[]).length%2===1,gr=e=>{let t=Ia(e);if(t!==null)return t;let n=e.match(Go);if(n&&!Pa(e)){let o=n[2];if(!o||ee.test(o))return e;if(Vo(e)%2===1)return `${e}\``}return e};var hr=(e,t)=>t>=2&&e.substring(t-2,t+1)==="```"||t>=1&&e.substring(t-1,t+2)==="```"||t<=e.length-3&&e.substring(t,t+3)==="```",Ta=e=>{let t=0,n=false;for(let o=0;o<e.length-1;o+=1)P(e,o)||(e[o]==="`"&&!hr(e,o)&&(n=!n),!n&&e[o]==="$"&&e[o+1]==="$"&&(t+=1,o+=1));return t},Ma=e=>{let t=0,n=false;for(let o=0;o<e.length;o+=1)if(!P(e,o)){if(e[o]==="\\"){o+=1;continue}if(e[o]==="`"&&!hr(e,o)){n=!n;continue}!n&&e[o]==="$"&&(o+1<e.length&&e[o+1]==="$"?o+=1:t+=1);}return t},xa=e=>{if(e.endsWith("$")&&!e.endsWith("$$"))return `${e}$`;let t=e.indexOf("$$");return t!==-1&&e.indexOf(`
48
+ `,t)!==-1&&!e.endsWith(`
49
+ `)?`${e}
50
+ $$`:`${e}$$`},br=e=>Ta(e)%2===0?e:xa(e),kr=e=>Ma(e)%2===1?`${e}$`:e;var La=(e,t,n)=>{if(e.substring(t+2).includes(")"))return null;let r=rr(e,t);if(r===-1||P(e,r)||D(e,r))return null;let s=r>0&&e[r-1]==="!",i=s?r-1:r,a=e.substring(0,i);if(s)return a;let l=e.substring(r+1,t);return n==="text-only"?`${a}${l}`:`${a}[${l}](markup:incomplete-link)`},yr=(e,t)=>{for(let n=0;n<t;n++)if(e[n]==="["&&!(P(e,n)||D(e,n))){if(n>0&&e[n-1]==="!")continue;let o=Wt(e,n);if(o===-1)return n;if(o+1<e.length&&e[o+1]==="("){let r=e.indexOf(")",o+2);r!==-1&&(n=r);}}return t},Na=(e,t,n)=>{let o=t>0&&e[t-1]==="!",r=o?t-1:t;if(!e.substring(t+1).includes("]")){let a=e.substring(0,r);if(o)return a;if(n==="text-only"){let l=yr(e,t);return e.substring(0,l)+e.substring(l+1)}return `${e}](markup:incomplete-link)`}if(Wt(e,t)===-1){let a=e.substring(0,r);if(o)return a;if(n==="text-only"){let l=yr(e,t);return e.substring(0,l)+e.substring(l+1)}return `${e}](markup:incomplete-link)`}return null},Vt=(e,t="protocol")=>{let n=e.lastIndexOf("](");if(n!==-1&&!(P(e,n)||D(e,n))){let o=La(e,n,t);if(o!==null)return o}for(let o=e.length-1;o>=0;o-=1)if(e[o]==="["&&!(P(e,o)||D(e,o))){let r=Na(e,o,t);if(r!==null)return r}return e};var Ra=/^-{1,2}$/,Sa=/^[\s]*-{1,2}[\s]+$/,Ea=/^={1,2}$/,Ba=/^[\s]*={1,2}[\s]+$/,Cr=e=>{if(!e||typeof e!="string")return e;let t=e.lastIndexOf(`
51
+ `);if(t===-1)return e;let n=e.substring(t+1),o=e.substring(0,t),r=n.trim();if(Ra.test(r)&&!n.match(Sa)){let i=o.split(`
52
+ `).at(-1);if(i&&i.trim().length>0)return `${e}\u200B`}if(Ea.test(r)&&!n.match(Ba)){let i=o.split(`
53
+ `).at(-1);if(i&&i.trim().length>0)return `${e}\u200B`}return e};var Aa=/(?<=[\p{L}\p{N}_])~(?!~)(?=[\p{L}\p{N}_])/gu,wr=e=>!e||typeof e!="string"||!e.includes("~")?e:e.replace(Aa,(t,n)=>P(e,n)||D(e,n)?t:"\\~");var vr=e=>Array.from(e.matchAll(or)).filter(t=>!P(e,t.index)).length,Ir=e=>{let t=e.match(Jo);if(t){let n=t[2];if(!n||ee.test(n))return e;let o=e.lastIndexOf(t[1]);if(P(e,o)||D(e,o)||Q(e,o))return e;if(vr(e)%2===1)return `${e}~~`}else {let n=e.match(nr);if(n){let o=e.lastIndexOf(n[0].slice(0,2));if(P(e,o)||D(e,o)||Q(e,o))return e;if(vr(e)%2===1)return `${e}~`}}return e};var zt=e=>e!==false,Ha=e=>e===true,V={SINGLE_TILDE:0,COMPARISON_OPERATORS:5,HTML_TAGS:10,SETEXT_HEADINGS:15,LINKS:20,BOLD_ITALIC:30,BOLD:35,ITALIC_DOUBLE_UNDERSCORE:40,ITALIC_SINGLE_ASTERISK:41,ITALIC_SINGLE_UNDERSCORE:42,INLINE_CODE:50,STRIKETHROUGH:60,KATEX:70,INLINE_KATEX:75,DEFAULT:100},Da=[{handler:{name:"singleTilde",handle:wr,priority:V.SINGLE_TILDE},optionKey:"singleTilde"},{handler:{name:"comparisonOperators",handle:zo,priority:V.COMPARISON_OPERATORS},optionKey:"comparisonOperators"},{handler:{name:"htmlTags",handle:fr,priority:V.HTML_TAGS},optionKey:"htmlTags"},{handler:{name:"setextHeadings",handle:Cr,priority:V.SETEXT_HEADINGS},optionKey:"setextHeadings"},{handler:{name:"links",handle:Vt,priority:V.LINKS},optionKey:"links",earlyReturn:e=>e.endsWith("](markup:incomplete-link)")},{handler:{name:"boldItalic",handle:pr,priority:V.BOLD_ITALIC},optionKey:"boldItalic"},{handler:{name:"bold",handle:lr,priority:V.BOLD},optionKey:"bold"},{handler:{name:"italicDoubleUnderscore",handle:cr,priority:V.ITALIC_DOUBLE_UNDERSCORE},optionKey:"italic"},{handler:{name:"italicSingleAsterisk",handle:dr,priority:V.ITALIC_SINGLE_ASTERISK},optionKey:"italic"},{handler:{name:"italicSingleUnderscore",handle:mr,priority:V.ITALIC_SINGLE_UNDERSCORE},optionKey:"italic"},{handler:{name:"inlineCode",handle:gr,priority:V.INLINE_CODE},optionKey:"inlineCode"},{handler:{name:"strikethrough",handle:Ir,priority:V.STRIKETHROUGH},optionKey:"strikethrough"},{handler:{name:"katex",handle:br,priority:V.KATEX},optionKey:"katex"},{handler:{name:"inlineKatex",handle:kr,priority:V.INLINE_KATEX},optionKey:"inlineKatex"}],Oa=e=>{var n;let t=(n=e==null?void 0:e.linkMode)!=null?n:"protocol";return Da.filter(({handler:o,optionKey:r})=>o.name==="links"?zt(e==null?void 0:e.links)||zt(e==null?void 0:e.images):o.name==="inlineKatex"?Ha(e==null?void 0:e.inlineKatex):zt(e==null?void 0:e[r])).map(({handler:o,earlyReturn:r})=>o.name==="links"?{handler:{...o,handle:s=>Vt(s,t)},earlyReturn:t==="protocol"?r:void 0}:{handler:o,earlyReturn:r})},_a=(e,t)=>{var a;if(!e||typeof e!="string")return e;let n=$e(e).at(-1);if(n&&!n.closed)return e;let o=e.endsWith(" ")&&!e.endsWith(" ")?e.slice(0,-1):e,r=Oa(t),s=((a=t==null?void 0:t.handlers)!=null?a:[]).map(l=>{var d;return {handler:{...l,priority:(d=l.priority)!=null?d:V.DEFAULT},earlyReturn:void 0}}),i=[...r,...s].sort((l,d)=>{var c,m;return ((c=l.handler.priority)!=null?c:0)-((m=d.handler.priority)!=null?m:0)});for(let{handler:l,earlyReturn:d}of i)if(o=l.handle(o),d!=null&&d(o))return o;return o},Pr=_a;var Ka=/^[ \t]*<[\w!/?-]/,qa=/(^|\n)[ \t]{4,}(?=<[\w!/?-])/g,Za=e=>typeof e!="string"||e.length===0||!Ka.test(e)?e:e.replace(qa,"$1"),Lr,Nr,Rr,Sr,it={...defaultSchema,protocols:{...defaultSchema.protocols,href:[...(Nr=(Lr=defaultSchema.protocols)==null?void 0:Lr.href)!=null?Nr:[],"tel"]},attributes:{...defaultSchema.attributes,code:[...((Sr=(Rr=defaultSchema.attributes)==null?void 0:Rr.code)!=null?Sr:[]).filter(e=>!Array.isArray(e)||e[0]!=="className"),["className",/^language-./,"math-inline","math-display"],"metastring"]}},Kt={raw:xo,sanitize:[Br,it],harden:[harden,{allowedImagePrefixes:["*"],allowedLinkPrefixes:["*"],allowedProtocols:["*"],defaultOrigin:void 0,allowDataImages:true}]},Xa={gfm:[Ua,{}],codeMeta:Fo},xr=Object.values(Kt),Ga=Object.values(Xa),Ja={block:" \u258B",circle:" \u25CF"},Ar=["github-light","github-dark"],Hr={enabled:true},Ya={shikiTheme:Ar,controls:true,isAnimating:false,lineNumbers:true,mode:"streaming",mermaid:void 0,linkSafety:Hr},B=createContext(Ya),Dr=memo(({content:e,shouldParseIncompleteMarkdown:t,shouldNormalizeHtmlIndentation:n,index:o,isIncomplete:r,dir:s,animatePlugin:i,...a})=>{if(i){let c=i.getLastRenderCharCount();i.setPrevContentLength(c);}let l=typeof e=="string"&&n?Za(e):e,d=jsx(Dt,{...a,children:l});return jsx(pt.Provider,{value:r,children:s?jsx("div",{dir:s,style:{display:"contents"},children:d}):d})},(e,t)=>{if(e.content!==t.content||e.shouldNormalizeHtmlIndentation!==t.shouldNormalizeHtmlIndentation||e.index!==t.index||e.isIncomplete!==t.isIncomplete||e.dir!==t.dir)return false;if(e.components!==t.components){let n=Object.keys(e.components||{}),o=Object.keys(t.components||{});if(n.length!==o.length||n.some(r=>{var s,i;return ((s=e.components)==null?void 0:s[r])!==((i=t.components)==null?void 0:i[r])}))return false}return !(e.rehypePlugins!==t.rehypePlugins||e.remarkPlugins!==t.remarkPlugins)});Dr.displayName="Block";var Qa=memo(({children:e,mode:t="streaming",dir:n,parseIncompleteMarkdown:o=true,normalizeHtmlIndentation:r=false,components:s,rehypePlugins:i=xr,remarkPlugins:a=Ga,className:l,shikiTheme:d=Ar,mermaid:c,controls:m=true,isAnimating:u=false,animated:f,BlockComponent:p=Dr,parseMarkdownIntoBlocksFn:h=Ie,caret:b,plugins:g,remend:y,linkSafety:w=Hr,lineNumbers:M=false,allowedTags:v,literalTagContent:x,translations:H,icons:A,prefix:q,onAnimationStart:Z,onAnimationEnd:F,..._})=>{let z=useId(),[re,ne]=useTransition(),T=useMemo(()=>sn(q),[q]),U=useRef(null),J=useRef(Z),Ve=useRef(F);J.current=Z,Ve.current=F,useEffect(()=>{var N,$,ae;if(t==="static")return;let I=U.current;if(U.current=u,I===null){u&&((N=J.current)==null||N.call(J));return}u&&!I?($=J.current)==null||$.call(J):!u&&I&&((ae=Ve.current)==null||ae.call(Ve));},[u,t]);let Te=useMemo(()=>v?Object.keys(v):[],[v]),Wr=JSON.stringify({...y,handlers:void 0}),Me=y==null?void 0:y.handlers,ze=useMemo(()=>{let I=N=>{let $=N;return x!=null&&x.length&&($=$o($,x)),Te.length&&($=_o($,Te)),$};return {preprocess:I,prepare:N=>I(o?Pr(N,y):N)}},[o,Wr,Me,Te,x]),qt=useMemo(()=>Oo({...ze,split:h,incremental:h===Ie&&!(Me!=null&&Me.length)&&!Te.length&&!(x!=null&&x.length)}),[ze,h,Me,Te,x]),Zt=useMemo(()=>t==="static"&&typeof e=="string"?ze.preprocess(e):"",[e,t,ze]),xe=useMemo(()=>t==="streaming"?qt.update(typeof e=="string"?e:"").blocks:[],[e,t,qt]),[Fr,Xt]=useState(xe);useEffect(()=>{t==="streaming"&&!Le?ne(()=>{Xt(xe);}):Xt(xe);},[xe,t]);let Y=t==="streaming"?Fr:xe,lt=useMemo(()=>n==="auto"?Y.map(nt):void 0,[Y,n]),Vr=useMemo(()=>Y.map((I,N)=>`${z}-${N}`),[Y.length,z]),ct=useMemo(()=>f===true?"true":f?JSON.stringify(f):"",[f]),Le=useMemo(()=>ct?ct==="true"?Ne():Ne(f):null,[ct]),Gt=useMemo(()=>{var I,N;return {shikiTheme:(N=(I=g==null?void 0:g.code)==null?void 0:I.getThemes())!=null?N:d,controls:m,isAnimating:u,lineNumbers:M,mode:t,mermaid:c,linkSafety:w}},[d,m,u,M,t,c,w,g==null?void 0:g.code]),zr=useMemo(()=>H?JSON.stringify(H):"",[H]),Jt=useMemo(()=>({...Ze,...H}),[zr]),Yt=useMemo(()=>{let{inlineCode:I,...N}=s!=null?s:{},$={...Po,...N};if(I){let ae=$.code;$.code=ge=>"data-block"in ge?ae?createElement(ae,ge):null:createElement(I,ge);}return $},[s]),Qt=useMemo(()=>{var N;let I=[];if(g!=null&&g.cjk&&(I=[...I,...g.cjk.remarkPluginsBefore]),I=[...I,...a],g!=null&&g.cjk&&(I=[...I,...g.cjk.remarkPluginsAfter]),g!=null&&g.math){let $=t==="streaming"&&o&&(N=g.math.remarkPluginStreaming)!=null?N:g.math.remarkPlugin;I=[...I,$];}return I},[a,g==null?void 0:g.math,g==null?void 0:g.cjk,t,o]),en=useMemo(()=>{var N;let I=i;if(v&&Object.keys(v).length>0&&i===xr){let $={...it,tagNames:[...(N=it.tagNames)!=null?N:[],...Object.keys(v)],attributes:{...it.attributes,...v}};I=[Kt.raw,[Br,$],Kt.harden];}return x&&x.length>0&&(I=[...I,[Wo,x]]),g!=null&&g.math&&(I=[...I,g.math.rehypePlugin]),Le&&u&&(I=[...I,Le.rehypePlugin]),I},[i,g==null?void 0:g.math,Le,u,v,x]),dt=useMemo(()=>{if(!u||Y.length===0)return false;let I=Y.at(-1);return Bt(I)||To(I)},[u,Y]),Ur=useMemo(()=>b&&u&&!dt?{"--markup-caret":`"${Ja[b]}"`}:void 0,[b,u,dt]);return t==="static"?jsx(Xe.Provider,{value:Jt,children:jsx(Ye.Provider,{value:g!=null?g:null,children:jsx(B.Provider,{value:Gt,children:jsx(Ct,{icons:A,children:jsx(Ue.Provider,{value:T,children:jsx("div",{className:T("space-y-4 whitespace-normal [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",l),dir:n==="auto"?nt(Zt):n,children:jsx(Dt,{components:Yt,rehypePlugins:en,remarkPlugins:Qt,..._,children:Zt})})})})})})}):jsx(Xe.Provider,{value:Jt,children:jsx(Ye.Provider,{value:g!=null?g:null,children:jsx(B.Provider,{value:Gt,children:jsx(Ct,{icons:A,children:jsx(Ue.Provider,{value:T,children:jsxs("div",{className:T("space-y-4 whitespace-normal [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",b&&!dt?"[&>*:last-child]:after:inline [&>*:last-child]:after:align-baseline [&>*:last-child]:after:content-[var(--markup-caret)]":null,l),style:Ur,children:[Y.length===0&&b&&u&&jsx("span",{}),Y.map((I,N)=>{var ge;let $=N===Y.length-1,ae=u&&$&&Bt(I);return jsx(p,{animatePlugin:Le,components:Yt,content:I,dir:(ge=lt==null?void 0:lt[N])!=null?ge:n!=="auto"?n:void 0,index:N,isIncomplete:ae,rehypePlugins:en,remarkPlugins:Qt,shouldNormalizeHtmlIndentation:r,shouldParseIncompleteMarkdown:o,..._},Vr[N])})]})})})})})})});Qa.displayName="Markup";var jr=({children:e,className:t,minZoom:n=.5,maxZoom:o=3,zoomStep:r=.1,showControls:s=true,initialZoom:i=1,fullscreen:a=false})=>{let{RotateCcwIcon:l,ZoomInIcon:d,ZoomOutIcon:c}=E(),m=k(),u=useRef(null),f=useRef(null),[p,h]=useState(i),[b,g]=useState({x:0,y:0}),[y,w]=useState(false),[M,v]=useState({x:0,y:0}),[x,H]=useState({x:0,y:0}),A=useCallback(T=>{h(U=>Math.max(n,Math.min(o,U+T)));},[n,o]),q=useCallback(()=>{A(r);},[A,r]),Z=useCallback(()=>{A(-r);},[A,r]),F=useCallback(()=>{h(i),g({x:0,y:0});},[i]),_=useCallback(T=>{T.preventDefault();let U=T.deltaY>0?-r:r;A(U);},[A,r]),z=useCallback(T=>{if(T.button!==0||T.isPrimary===false)return;w(true),v({x:T.clientX,y:T.clientY}),H(b);let U=T.currentTarget;U instanceof HTMLElement&&U.setPointerCapture(T.pointerId);},[b]),re=useCallback(T=>{if(!y)return;T.preventDefault();let U=T.clientX-M.x,J=T.clientY-M.y;g({x:x.x+U,y:x.y+J});},[y,M,x]),ne=useCallback(T=>{w(false);let U=T.currentTarget;U instanceof HTMLElement&&U.releasePointerCapture(T.pointerId);},[]);return useEffect(()=>{let T=u.current;if(T)return T.addEventListener("wheel",_,{passive:false}),()=>{T.removeEventListener("wheel",_);}},[_]),useEffect(()=>{let T=f.current;if(T&&y)return document.body.style.userSelect="none",T.addEventListener("pointermove",re,{passive:false}),T.addEventListener("pointerup",ne),T.addEventListener("pointercancel",ne),()=>{document.body.style.userSelect="",T.removeEventListener("pointermove",re),T.removeEventListener("pointerup",ne),T.removeEventListener("pointercancel",ne);}},[y,re,ne]),jsxs("div",{className:m("relative flex flex-col",a?"h-full w-full":"min-h-28 w-full",t),ref:u,style:{cursor:y?"grabbing":"grab"},children:[s?jsxs("div",{className:m("absolute z-10 flex flex-col gap-1 rounded-md border border-border bg-background/80 p-1 supports-[backdrop-filter]:bg-background/70 supports-[backdrop-filter]:backdrop-blur-sm",a?"bottom-4 left-4":"bottom-2 left-2"),children:[jsx("button",{className:m("flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50"),disabled:p>=o,onClick:q,title:"Zoom in",type:"button",children:jsx(d,{size:16})}),jsx("button",{className:m("flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50"),disabled:p<=n,onClick:Z,title:"Zoom out",type:"button",children:jsx(c,{size:16})}),jsx("button",{className:m("flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground"),onClick:F,title:"Reset zoom and pan",type:"button",children:jsx(l,{size:16})})]}):null,jsx("div",{className:m("flex-1 origin-center transition-transform duration-150 ease-out",a?"flex h-full w-full items-center justify-center":"flex w-full items-center justify-center"),onPointerDown:z,ref:f,role:"application",style:{transform:`translate(${b.x}px, ${b.y}px) scale(${p})`,transformOrigin:"center center",touchAction:"none",willChange:"transform"},children:e})]})};var Wn=({chart:e,className:t,config:n,fullscreen:o=false,showControls:r=true})=>{let s=k(),[i,a]=useState(null),[l,d]=useState(false),[c,m]=useState(""),[u,f]=useState(""),[p,h]=useState(0),{mermaid:b}=useContext(B),g=ke(),y=b==null?void 0:b.errorComponent,{shouldRender:w,containerRef:M}=tn({immediate:o});if(useEffect(()=>{if(!w)return;if(!g){a("Mermaid plugin not available. Please add the mermaid plugin to enable diagram rendering.");return}(async()=>{try{a(null),d(!0);let H=g.getMermaid(n),A=e.split("").reduce((F,_)=>(F<<5)-F+_.charCodeAt(0)|0,0),q=`mermaid-${Math.abs(A)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:Z}=await H.render(q,e);m(Z),f(Z);}catch(H){if(!(u||c)){let A=H instanceof Error?H.message:"Failed to render Mermaid chart";a(A);}}finally{d(false);}})();},[e,n,p,w,g]),!(w||c||u))return jsx("div",{className:s("my-4 min-h-[200px]",t),ref:M});if(l&&!c&&!u)return jsx("div",{className:s("my-4 flex justify-center p-4",t),ref:M,children:jsxs("div",{className:s("flex items-center space-x-2 text-muted-foreground"),children:[jsx("div",{className:s("h-4 w-4 animate-spin rounded-full border-current border-b-2")}),jsx("span",{className:s("text-sm"),children:"Loading diagram..."})]})});if(i&&!c&&!u){let x=()=>h(H=>H+1);return y?jsx("div",{ref:M,children:jsx(y,{chart:e,error:i,retry:x})}):jsxs("div",{className:s("rounded-md bg-red-50 p-4",t),ref:M,children:[jsxs("p",{className:s("font-mono text-red-700 text-sm"),children:["Mermaid Error: ",i]}),jsxs("details",{className:s("mt-2"),children:[jsx("summary",{className:s("cursor-pointer text-red-600 text-xs"),children:"Show Code"}),jsx("pre",{className:s("mt-2 overflow-x-auto rounded bg-red-100 p-2 text-red-800 text-xs"),children:e})]})]})}let v=c||u;return jsx("div",{className:s("size-full",t),"data-markup":"mermaid",ref:M,children:jsx(jr,{className:s(o?"size-full overflow-hidden":"overflow-hidden",t),fullscreen:o,maxZoom:3,minZoom:.5,showControls:r,zoomStep:.1,children:jsx("div",{"aria-label":"Mermaid chart",className:s("flex justify-center",o?"size-full items-center":null),dangerouslySetInnerHTML:{__html:v},role:"img"})})})};export{Xa as A,B,Dr as C,Qa as D,Ne as a,ft as b,dn as c,gt as d,kt as e,Nc as f,yt as g,Ze as h,Ge as i,wt as j,Je as k,Wn as l,de as m,ue as n,Pt as o,Qe as p,se as q,De as r,Qs as s,oi as t,Oe as u,nt as v,So as w,Ie as x,Za as y,Kt as z};
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import {B,f,c}from'./chunk-WV2NZ4BQ.js';import {useContext,useState,useEffect}from'react';import {jsx}from'react/jsx-runtime';var R=({code:s,language:e,raw:t,className:h,startLine:d,lineNumbers:m,...p})=>{let{shikiTheme:l}=useContext(B),o=f(),[a,i]=useState(t);return useEffect(()=>{if(!o){i(t);return}let r=o.highlight({code:s,language:e,themes:l},c=>{i(c);});r&&i(r);},[s,e,l,o,t]),jsx(c,{className:h,language:e,lineNumbers:m,result:a,startLine:d,...p})};export{R as HighlightedCodeBlockBody};
2
+ import {B,f,c}from'./chunk-5L4J6AEU.js';import {useContext,useState,useEffect}from'react';import {jsx}from'react/jsx-runtime';var R=({code:s,language:e,raw:t,className:h,startLine:d,lineNumbers:m,...p})=>{let{shikiTheme:l}=useContext(B),o=f(),[a,i]=useState(t);return useEffect(()=>{if(!o){i(t);return}let r=o.highlight({code:s,language:e,themes:l},c=>{i(c);});r&&i(r);},[s,e,l,o,t]),jsx(c,{className:h,language:e,lineNumbers:m,result:a,startLine:d,...p})};export{R as HighlightedCodeBlockBody};
package/dist/index.d.ts CHANGED
@@ -8,62 +8,6 @@ import { Options as Options$1 } from 'remark-rehype';
8
8
  import { BundledTheme, ThemeRegistrationAny, BundledLanguage } from 'shiki';
9
9
  export { BundledLanguage, BundledTheme, ThemeRegistrationAny } from 'shiki';
10
10
 
11
- /**
12
- * Handler function that transforms text during streaming.
13
- */
14
- interface RemendHandler {
15
- /** Handler function: takes text, returns modified text */
16
- handle: (text: string) => string;
17
- /** Unique identifier for this handler */
18
- name: string;
19
- /** Priority (lower runs first). Built-in priorities: 0-100. Default: 100 */
20
- priority?: number;
21
- }
22
- /**
23
- * Configuration options for the remend function.
24
- * Options default to `true` unless noted otherwise.
25
- * Set an option to `false` to disable that specific completion.
26
- */
27
- interface RemendOptions {
28
- /** Complete bold formatting (e.g., `**text` → `**text**`) */
29
- bold?: boolean;
30
- /** Complete bold-italic formatting (e.g., `***text` → `***text***`) */
31
- boldItalic?: boolean;
32
- /** Escape > as comparison operators in list items (e.g., `- > 25` → `- \> 25`) */
33
- comparisonOperators?: boolean;
34
- /** Custom handlers to extend remend */
35
- handlers?: RemendHandler[];
36
- /** Strip incomplete HTML tags at end of streaming text (e.g., `text <custom` → `text`) */
37
- htmlTags?: boolean;
38
- /** Complete images (e.g., `![alt](url` → removed) */
39
- images?: boolean;
40
- /** Complete inline code formatting (e.g., `` `code `` → `` `code` ``) */
41
- inlineCode?: boolean;
42
- /**
43
- * Complete inline KaTeX math (e.g., `$equation` → `$equation$`).
44
- * Defaults to `false` — single `$` is ambiguous with currency symbols.
45
- */
46
- inlineKatex?: boolean;
47
- /** Complete italic formatting (e.g., `*text` → `*text*` or `_text` → `_text_`) */
48
- italic?: boolean;
49
- /** Complete block KaTeX math (e.g., `$$equation` → `$$equation$$`) */
50
- katex?: boolean;
51
- /**
52
- * How to handle incomplete links:
53
- * - `'protocol'`: Use `streamdown:incomplete-link` placeholder URL (default)
54
- * - `'text-only'`: Display only the link text without any link markup
55
- */
56
- linkMode?: "protocol" | "text-only";
57
- /** Complete links and images (e.g., `[text](url` → `[text](streamdown:incomplete-link)`) */
58
- links?: boolean;
59
- /** Handle incomplete setext headings to prevent misinterpretation */
60
- setextHeadings?: boolean;
61
- /** Escape single ~ between word characters to prevent false strikethrough (e.g., `20~25` → `20\~25`) */
62
- singleTilde?: boolean;
63
- /** Complete strikethrough formatting (e.g., `~~text` → `~~text~~`) */
64
- strikethrough?: boolean;
65
- }
66
-
67
11
  interface AnimatePlugin {
68
12
  /**
69
13
  * Returns the total HAST text node character count from the last
@@ -227,6 +171,8 @@ interface MathPlugin {
227
171
  * Get remark plugin for parsing math syntax
228
172
  */
229
173
  remarkPlugin: Pluggable;
174
+ /** Optional parser for unfinished math in streaming snapshots. */
175
+ remarkPluginStreaming?: Pluggable;
230
176
  type: "math";
231
177
  }
232
178
  /**
@@ -265,7 +211,7 @@ interface CustomRenderer {
265
211
  language: string | string[];
266
212
  }
267
213
  /**
268
- * Plugin configuration passed to Streamdown
214
+ * Plugin configuration passed to Markup
269
215
  */
270
216
  interface PluginConfig {
271
217
  cjk?: CjkPlugin;
@@ -275,7 +221,7 @@ interface PluginConfig {
275
221
  renderers?: CustomRenderer[];
276
222
  }
277
223
 
278
- interface StreamdownTranslations {
224
+ interface MarkupTranslations {
279
225
  close: string;
280
226
  copied: string;
281
227
  copyCode: string;
@@ -306,7 +252,63 @@ interface StreamdownTranslations {
306
252
  tableFormatTsv: string;
307
253
  viewFullscreen: string;
308
254
  }
309
- declare const defaultTranslations: StreamdownTranslations;
255
+ declare const defaultTranslations: MarkupTranslations;
256
+
257
+ /**
258
+ * Handler function that transforms text during streaming.
259
+ */
260
+ interface RemendHandler {
261
+ /** Handler function: takes text, returns modified text */
262
+ handle: (text: string) => string;
263
+ /** Unique identifier for this handler */
264
+ name: string;
265
+ /** Priority (lower runs first). Built-in priorities: 0-100. Default: 100 */
266
+ priority?: number;
267
+ }
268
+ /**
269
+ * Configuration options for the remend function.
270
+ * Options default to `true` unless noted otherwise.
271
+ * Set an option to `false` to disable that specific completion.
272
+ */
273
+ interface RemendOptions {
274
+ /** Complete bold formatting (e.g., `**text` → `**text**`) */
275
+ bold?: boolean;
276
+ /** Complete bold-italic formatting (e.g., `***text` → `***text***`) */
277
+ boldItalic?: boolean;
278
+ /** Escape > as comparison operators in list items (e.g., `- > 25` → `- \> 25`) */
279
+ comparisonOperators?: boolean;
280
+ /** Custom handlers to extend remend */
281
+ handlers?: RemendHandler[];
282
+ /** Strip incomplete HTML tags at end of streaming text (e.g., `text <custom` → `text`) */
283
+ htmlTags?: boolean;
284
+ /** Complete images (e.g., `![alt](url` → removed) */
285
+ images?: boolean;
286
+ /** Complete inline code formatting (e.g., `` `code `` → `` `code` ``) */
287
+ inlineCode?: boolean;
288
+ /**
289
+ * Complete inline KaTeX math (e.g., `$equation` → `$equation$`).
290
+ * Defaults to `false` — single `$` is ambiguous with currency symbols.
291
+ */
292
+ inlineKatex?: boolean;
293
+ /** Complete italic formatting (e.g., `*text` → `*text*` or `_text` → `_text_`) */
294
+ italic?: boolean;
295
+ /** Complete block KaTeX math (e.g., `$$equation` → `$$equation$$`) */
296
+ katex?: boolean;
297
+ /**
298
+ * How to handle incomplete links:
299
+ * - `'protocol'`: Use `markup:incomplete-link` placeholder URL (default)
300
+ * - `'text-only'`: Display only the link text without any link markup
301
+ */
302
+ linkMode?: "protocol" | "text-only";
303
+ /** Complete links and images (e.g., `[text](url` → `[text](markup:incomplete-link)`) */
304
+ links?: boolean;
305
+ /** Handle incomplete setext headings to prevent misinterpretation */
306
+ setextHeadings?: boolean;
307
+ /** Escape single ~ between word characters to prevent false strikethrough (e.g., `20~25` → `20\~25`) */
308
+ singleTilde?: boolean;
309
+ /** Complete strikethrough formatting (e.g., `~~text` → `~~text~~`) */
310
+ strikethrough?: boolean;
311
+ }
310
312
 
311
313
  /**
312
314
  * Hook to check if the current block has an incomplete (unclosed) code fence.
@@ -470,7 +472,7 @@ interface MermaidOptions {
470
472
  errorComponent?: React.ComponentType<MermaidErrorComponentProps>;
471
473
  }
472
474
  type AllowedTags = Record<string, string[]>;
473
- type StreamdownProps = Options & {
475
+ type MarkupProps = Options & {
474
476
  mode?: "static" | "streaming";
475
477
  /** Text direction for blocks. "auto" detects per-block using first strong character algorithm. */
476
478
  dir?: "auto" | "ltr" | "rtl";
@@ -498,17 +500,17 @@ type StreamdownProps = Options & {
498
500
  *
499
501
  * @example
500
502
  * ```tsx
501
- * <Streamdown
503
+ * <Markup
502
504
  * allowedTags={{ mention: ['user_id'] }}
503
505
  * literalTagContent={['mention']}
504
506
  * >
505
507
  * {`<mention user_id="123">@_some_username_</mention>`}
506
- * </Streamdown>
508
+ * </Markup>
507
509
  * ```
508
510
  */
509
511
  literalTagContent?: string[];
510
512
  /** Override UI strings for i18n / custom labels */
511
- translations?: Partial<StreamdownTranslations>;
513
+ translations?: Partial<MarkupTranslations>;
512
514
  /** Custom icons to override the default icons used in controls */
513
515
  icons?: Partial<IconMap>;
514
516
  /** Tailwind CSS prefix to prepend to all utility classes (e.g. `"tw"` produces `tw:flex` instead of `flex`). Enables Tailwind v4's `prefix()` support. Note: user-supplied `className` values are also prefixed. */
@@ -526,7 +528,7 @@ declare const carets: {
526
528
  block: string;
527
529
  circle: string;
528
530
  };
529
- interface StreamdownContextType {
531
+ interface MarkupContextType {
530
532
  controls: ControlsConfig;
531
533
  isAnimating: boolean;
532
534
  /** Show line numbers in code blocks. @default true */
@@ -536,7 +538,7 @@ interface StreamdownContextType {
536
538
  mode: "static" | "streaming";
537
539
  shikiTheme: [ThemeInput, ThemeInput];
538
540
  }
539
- declare const StreamdownContext: react.Context<StreamdownContextType>;
541
+ declare const MarkupContext: react.Context<MarkupContextType>;
540
542
  type BlockProps = Options & {
541
543
  content: string;
542
544
  shouldParseIncompleteMarkdown: boolean;
@@ -550,6 +552,6 @@ type BlockProps = Options & {
550
552
  animatePlugin?: AnimatePlugin | null;
551
553
  };
552
554
  declare const Block: react.MemoExoticComponent<({ content, shouldParseIncompleteMarkdown: _, shouldNormalizeHtmlIndentation, index: __, isIncomplete, dir, animatePlugin: animatePluginProp, ...props }: BlockProps) => react_jsx_runtime.JSX.Element>;
553
- declare const Markup: react.MemoExoticComponent<({ children, mode, dir, parseIncompleteMarkdown: shouldParseIncompleteMarkdown, normalizeHtmlIndentation: shouldNormalizeHtmlIndentation, components, rehypePlugins, remarkPlugins, className, shikiTheme, mermaid, controls, isAnimating, animated, BlockComponent, parseMarkdownIntoBlocksFn, caret, plugins, remend: remendOptions, linkSafety, lineNumbers, allowedTags, literalTagContent, translations, icons: iconOverrides, prefix, onAnimationStart, onAnimationEnd, ...props }: StreamdownProps) => react_jsx_runtime.JSX.Element>;
555
+ declare const Markup: react.MemoExoticComponent<({ children, mode, dir, parseIncompleteMarkdown: shouldParseIncompleteMarkdown, normalizeHtmlIndentation: shouldNormalizeHtmlIndentation, components, rehypePlugins, remarkPlugins, className, shikiTheme, mermaid, controls, isAnimating, animated, BlockComponent, parseMarkdownIntoBlocksFn, caret, plugins, remend: remendOptions, linkSafety, lineNumbers, allowedTags, literalTagContent, translations, icons: iconOverrides, prefix, onAnimationStart, onAnimationEnd, ...props }: MarkupProps) => react_jsx_runtime.JSX.Element>;
554
556
 
555
- export { type AllowElement, type AllowedTags, type AnimateOptions, Block, type BlockProps, type CjkPlugin, CodeBlock, CodeBlockContainer, CodeBlockCopyButton, CodeBlockDownloadButton, CodeBlockHeader, CodeBlockSkeleton, type CodeHighlighterPlugin, type Components, type ControlsConfig, type CustomRenderer, type CustomRendererProps, type DiagramPlugin, type ExtraProps, type HighlightOptions, type IconMap, type LinkSafetyConfig, type LinkSafetyModalProps, Markup, type MathPlugin, type MermaidErrorComponentProps, type MermaidOptions, type PluginConfig, StreamdownContext, type StreamdownContextType, type StreamdownProps, type StreamdownTranslations, TableCopyButton, type TableCopyButtonProps, TableCopyDropdown, type TableCopyDropdownProps, type TableData, TableDownloadButton, type TableDownloadButtonProps, TableDownloadDropdown, type TableDownloadDropdownProps, type ThemeInput, type UrlTransform, createAnimatePlugin, defaultRehypePlugins, defaultRemarkPlugins, defaultTranslations, defaultUrlTransform, detectTextDirection, escapeMarkdownTableCell, extractTableDataFromElement, normalizeHtmlIndentation, parseMarkdownIntoBlocks, tableDataToCSV, tableDataToMarkdown, tableDataToTSV, useIsCodeFenceIncomplete };
557
+ export { type AllowElement, type AllowedTags, type AnimateOptions, Block, type BlockProps, type CjkPlugin, CodeBlock, CodeBlockContainer, CodeBlockCopyButton, CodeBlockDownloadButton, CodeBlockHeader, CodeBlockSkeleton, type CodeHighlighterPlugin, type Components, type ControlsConfig, type CustomRenderer, type CustomRendererProps, type DiagramPlugin, type ExtraProps, type HighlightOptions, type IconMap, type LinkSafetyConfig, type LinkSafetyModalProps, Markup, MarkupContext, type MarkupContextType, type MarkupProps, type MarkupTranslations, type MathPlugin, type MermaidErrorComponentProps, type MermaidOptions, type PluginConfig, TableCopyButton, type TableCopyButtonProps, TableCopyDropdown, type TableCopyDropdownProps, type TableData, TableDownloadButton, type TableDownloadButtonProps, TableDownloadDropdown, type TableDownloadDropdownProps, type ThemeInput, type UrlTransform, createAnimatePlugin, defaultRehypePlugins, defaultRemarkPlugins, defaultTranslations, defaultUrlTransform, detectTextDirection, escapeMarkdownTableCell, extractTableDataFromElement, normalizeHtmlIndentation, parseMarkdownIntoBlocks, tableDataToCSV, tableDataToMarkdown, tableDataToTSV, useIsCodeFenceIncomplete };
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- export{C as Block,g as CodeBlock,d as CodeBlockContainer,i as CodeBlockCopyButton,j as CodeBlockDownloadButton,e as CodeBlockHeader,k as CodeBlockSkeleton,D as Markup,B as StreamdownContext,r as TableCopyButton,s as TableCopyDropdown,t as TableDownloadButton,u as TableDownloadDropdown,a as createAnimatePlugin,z as defaultRehypePlugins,A as defaultRemarkPlugins,h as defaultTranslations,w as defaultUrlTransform,v as detectTextDirection,p as escapeMarkdownTableCell,m as extractTableDataFromElement,y as normalizeHtmlIndentation,x as parseMarkdownIntoBlocks,n as tableDataToCSV,q as tableDataToMarkdown,o as tableDataToTSV,b as useIsCodeFenceIncomplete}from'./chunk-3FMAEQDM.js';
2
+ export{C as Block,g as CodeBlock,d as CodeBlockContainer,i as CodeBlockCopyButton,j as CodeBlockDownloadButton,e as CodeBlockHeader,k as CodeBlockSkeleton,D as Markup,B as MarkupContext,r as TableCopyButton,s as TableCopyDropdown,t as TableDownloadButton,u as TableDownloadDropdown,a as createAnimatePlugin,z as defaultRehypePlugins,A as defaultRemarkPlugins,h as defaultTranslations,w as defaultUrlTransform,v as detectTextDirection,p as escapeMarkdownTableCell,m as extractTableDataFromElement,y as normalizeHtmlIndentation,x as parseMarkdownIntoBlocks,n as tableDataToCSV,q as tableDataToMarkdown,o as tableDataToTSV,b as useIsCodeFenceIncomplete}from'./chunk-5L4J6AEU.js';
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ export{l as Mermaid}from'./chunk-5L4J6AEU.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aseity/markup",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -17,20 +17,7 @@
17
17
  "styles.css",
18
18
  "README.md"
19
19
  ],
20
- "scripts": {
21
- "build": "tsup",
22
- "postbuild": "node scripts/postbuild.js",
23
- "test": "vitest run",
24
- "test:ui": "vitest --ui run",
25
- "test:coverage": "vitest --coverage run",
26
- "bench": "vitest bench --run > results.txt",
27
- "bench:ui": "vitest bench --ui --run",
28
- "size": "node scripts/bundle-size.js"
29
- },
30
20
  "devDependencies": {
31
- "@streamdown/cjk": "workspace:*",
32
- "@aseity/markup-math": "workspace:*",
33
- "@streamdown/mermaid": "workspace:*",
34
21
  "@testing-library/jest-dom": "^6.9.1",
35
22
  "@testing-library/react": "^16.3.0",
36
23
  "@types/hast": "^3.0.4",
@@ -45,7 +32,12 @@
45
32
  "rehype-stringify": "^10.0.1",
46
33
  "shiki": "^3.19.0",
47
34
  "tsup": "^8.5.1",
48
- "vitest": "^4.0.15"
35
+ "vitest": "^4.0.15",
36
+ "@types/mdast": "^4.0.4",
37
+ "@types/unist": "^3.0.3",
38
+ "@aseity/markup-cjk": "0.0.1",
39
+ "@aseity/markup-mermaid": "0.0.1",
40
+ "@aseity/markup-math": "0.0.1"
49
41
  },
50
42
  "peerDependencies": {
51
43
  "react": "^18.0.0 || ^19.0.0",
@@ -67,5 +59,25 @@
67
59
  "mermaid": "^11.12.2",
68
60
  "unist-util-visit": "^5.0.0",
69
61
  "unist-util-visit-parents": "^6.0.0"
62
+ },
63
+ "license": "Apache-2.0",
64
+ "publishConfig": {
65
+ "access": "public",
66
+ "registry": "https://registry.npmjs.org/"
67
+ },
68
+ "repository": {
69
+ "type": "git",
70
+ "url": "git+https://github.com/Ty026/aseity-markup.git",
71
+ "directory": "packages/markup"
72
+ },
73
+ "scripts": {
74
+ "build": "tsup",
75
+ "postbuild": "node scripts/postbuild.js",
76
+ "test": "vitest run",
77
+ "test:ui": "vitest --ui run",
78
+ "test:coverage": "vitest --coverage run",
79
+ "bench": "vitest bench --run > results.txt",
80
+ "bench:ui": "vitest bench --ui --run",
81
+ "size": "node scripts/bundle-size.js"
70
82
  }
71
- }
83
+ }